mirror of
https://github.com/logos-messaging/sds-go-bindings.git
synced 2026-07-24 17:03:17 +00:00
nim-sds now builds on nim-ffi 0.2, whose wire format is CBOR (not JSON)
and whose events use a per-event listener registry. Rewrite the cgo layer
to match:
- requests/responses are CBOR (fxamacker/cbor); seq[byte] is a CBOR byte
string; request params are wrapped under their Nim param name ("req"/
"config"). No-arg methods send an empty CBOR map (0xa0).
- register one listener per event via sds_add_event_listener; decode the
CBOR EventEnvelope {eventType,payload}. Adds OnRepairReady.
- copy the result payload during the callback (libsds frees it on return)
and key the waiter by the C resp pointer in a sync.Map with LoadAndDelete
(winner-takes-all) — no Go pointer is stored in C memory, and a late or
duplicate delivery cannot double-close or touch a freed resp.
- guard the manager registry with a RWMutex (callbacks run on libsds
threads).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>