Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

SDS Go Bindings

This repository provides Go bindings for the SDS library, enabling seamless integration with Go projects.

Outgoing message callbacks

EventCallbacks.OnMessageSent reports acknowledgment evidence from incoming causal history or bloom filters. OnMessageExpired reports an unacknowledged message removed after the native sweep budget is exhausted. Both callbacks receive the message ID and channel ID; expiry must not be interpreted as delivery. Leaving OnMessageExpired unset does not route expiry to OnMessageSent.

Native sweep timing and counters are unchanged. The sweep counts elapsed resend intervals, not actual transmissions, and does not transmit retries.

Periodic sync messages

Call EnsureChannel(channelID) for channels to monitor, including after a restart. Call Tick() regularly; it returns due payloads tagged with their channel IDs for the caller to publish. A TickEvent may instead contain an error for one channel; other channel results are still returned. An overall error can also accompany events generated before the failure; process those events even when Tick() returns an error.

NewReliabilityManager uses the native default interval of 30 seconds. Use NewReliabilityManagerWithSyncInterval to set another positive interval in whole milliseconds; zero selects the default.

UnwrapReceivedMessage processes sync metadata and returns a nil Message because a sync has no application payload. Missing dependencies are still reported in MissingDeps; unwrap errors remain separate. Use ChannelRetrievalHintProvider when retrieval hints depend on the channel; the older message-ID-only callback remains supported as a fallback.

Incoming message authorization

Register a sds.Authorizer with SetAuthorizer before receiving messages; it returns after the native worker applies the change. Pass nil to clear the authorizer. Use UnwrapReceivedMessageWithContext to pass request-local host context such as an authenticated transport identity. This context is not part of the wire message. Authorizers run synchronously on the native worker and must not re-enter the same manager.

The API and authorization semantics are documented in nim-sds' incoming message authorization guide.

Persistence

Pass an implementation of the sds.PersistenceCallbacks interface to sds.NewReliabilityManager to persist channel state. Implement all four methods (SaveChannelMeta, UpdateHistory, LoadChannel, and DropChannel), or pass nil as the second argument for in-memory operation: sds.NewReliabilityManager(logger, nil). The persistence argument is now required; existing calls with only a logger must add nil.

Metadata and serialized history messages are opaque byte slices. History updates contain messages to append and IDs to evict; apply each update transactionally. Loading a new channel must return an empty sds.ChannelData without an error. Return storage errors from the methods rather than silently discarding them.

The Nimble dependency is pinned to a nim-sds commit that includes persistence callbacks, the ensureChannel/tick sync API, and manager-scoped authorizers.

Persistence restores duplicate detection across manager restarts. SDS-R repair remains disabled because these bindings leave the participant ID empty.

UnwrapReceivedMessage returns an error matching sds.ErrNotSDS when native SDS cannot deserialize the input. Callers supporting legacy unwrapped messages may pass through that input. Other errors, including persisted-state loading and response-decoding failures, must not be treated as unwrapped payloads.

Installation

These bindings link against libsds, the C library of nim-sds. An application that already builds libsds points cgo at it:

CGO_CFLAGS="-I<dir with libsds.h>" CGO_LDFLAGS="-L<dir with libsds> -lsds" go build ./...

libsds.h includes generated/sds.h, which nim-sds writes next to it.

To build libsds here, from the nim-sds revision nimble.lock pins, with Nimble 0.26 or newer on PATH:

make libsds        # builds libsds into build/
make print-cgo     # the cgo flags for that build, to run Go yourself
make test          # builds libsds into build/, then runs the Go tests

libsds builds with ORC; pass NIM_PARAMS to build it with other Nim flags. On Windows, add build to PATH when running tests. Platform-specific libsds builds are owned by the consuming application.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages