Igor SirotinandClaude Opus 5 7b138bf71f feat: Messaging API (MessagingClient) (#120)
* feat(messaging): object-oriented Go mirror of the Nim MessagingClient

Adds pkg/messaging: a high-level, idiomatic Go binding for the Messaging
API, mirroring logos-delivery's Nim MessagingClient. A MessagingClient owns
a node and carries the messaging surface as methods on it — New / Start /
Stop / Close, Subscribe / Unsubscribe, Send(ctx, Envelope) (RequestID,
error) — over internal/ffi rather than exposing the raw FFI.

Events arrive on a single Events() <-chan Event with a sealed Event
interface: MessageReceivedEvent, MessageSentEvent, MessagePropagatedEvent,
MessageErrorEvent and ConnectionStatusEvent. Delivery never blocks the
library's event thread; an event is dropped when a consumer falls behind.
Config marshals to the layered configuration JSON (mode / preset /
messagingOverrides / channelsOverrides), with every field omitempty so it
can never be mistaken for the legacy flat blob.

Migrating internal/ffi to the current C ABI comes with it, because the
generated surface has moved on since the bridge was written and no longer
compiles: nim-ffi now generates the header from the {.ffi.} annotations,
argument-taking calls pass a per-call <Name>Req struct and a typed
<Name>ReplyFn, no-argument calls take a raw scalar callback, destroy is
synchronous, and the single set_event_callback has been replaced by a
per-event listener registry. The bridge now also copies every callback
string while it is still borrowed, and ignores the non-terminal
STALE_WARN progress code instead of settling the call on it.

pkg/kernel follows the same listener change, registering the three kernel
events it already consumed.

Verified against a liblogosdelivery built from logos-delivery master:
build / vet / golangci-lint / go mod tidy clean, unit tests green, and the
tagged integration test does a full create-start-subscribe-send round trip
on logos.dev, observing the message back and its propagation confirmation.

Closes #119.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CnzdnSMtHM5aLHLtDGBGR9

* review: address feedback on the MessagingClient API

- Send takes contentTopic / payload / ephemeral directly instead of an
  Envelope struct, which drops the Envelope type; ContentTopic and RequestID
  move to types.go.
- messagingEvents becomes a function returning the slice, so the set cannot
  be mutated by accident.
- Document what seals the Event interface and what that buys callers.
- Document why the received payload is decoded from a JSON integer array:
  base64 is only used on the send path and by the channel events, not by the
  messaging events.

* ci: stop golangci-lint's config verify from failing on a network timeout

golangci-lint-action runs `golangci-lint config verify` before linting, which
fetches the v2.4 JSON schema from golangci-lint.run on every run. That request
timed out on the runner and failed the gate with no lint finding behind it. An
invalid config still fails the lint run itself, so the pre-check only costs a
network dependency.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 11:53:36 +01:00
2025-12-22 14:15:00 +05:30

logos-delivery Go Bindings

Go bindings for the Waku library.

Packages

  • pkg/messaging — the high-level Messaging API, and the one to reach for. A MessagingClient mirrors the Nim MessagingClient: it owns a node and exposes Start/Stop/Close, Subscribe/Unsubscribe, Send, and a typed Events() stream. See examples/messaging for a runnable demo.
  • pkg/kernel — the low-level kernel (waku_*) protocols: relay, store, filter, lightpush, discovery and peer management. Unsupported and subject to change without notice.

Install

go get -u github.com/logos-messaging/logos-delivery-go-bindings

Building & Dependencies

libwaku (from logos-delivery) is required at compile-time.

Building with Makefile

If you have logos-delivery checked out, point the build to it:

# path to your existing logos-delivery clone
export LOGOS_DELIVERY_DIR=/absolute/path/to/logos-delivery
export CGO_CFLAGS="-I${LOGOS_DELIVERY_DIR}/library"
export CGO_LDFLAGS="-L${LOGOS_DELIVERY_DIR}/build -lwaku -Wl,-rpath,${LOGOS_DELIVERY_DIR}/build"

# compile all packages
make -C pkg/kernel build

# run all tests
make -C pkg/kernel test

# run a specific test
make -C pkg/kernel test TEST=TestConnectedPeersInfo

Development

When working on this repository itself, logos-delivery is included as a git submodule for convenience.

  • Initialize and update the submodule, then build libwaku
    git submodule update --init --recursive
    make -C pkg/kernel build-libwaku
    
  • Build the project. Submodule paths are used by default to find libwaku.
    make -C pkg/kernel build
    
S
Description
No description provided
Readme
16 MiB
Languages
Go 99.1%
Makefile 0.9%