mirror of
https://github.com/logos-messaging/sds-go-bindings.git
synced 2026-07-24 00:43:17 +00:00
fix: pass a non-empty participantId to enable SDS-R
The pre-nim-ffi binding had no participantId concept; mirroring that with an empty id disables SDS-R, but the new libsds unwrap path SIGSEGVs on real received messages in that configuration. Generate a random per-manager participantId so SDS-R is enabled, matching the nim-ffi 0.2.0 SDS-R/retrieval-hint design intent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
a5a47f8e6e
commit
bf71cacb9a
24
sds/sds.go
24
sds/sds.go
@ -110,6 +110,8 @@ package sds
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"sync"
|
||||
"unsafe"
|
||||
@ -132,6 +134,15 @@ var eventNames = []string{
|
||||
eventPeriodicSync,
|
||||
}
|
||||
|
||||
// randomParticipantID returns a random hex-encoded SDS-R participant identity.
|
||||
func randomParticipantID() (string, error) {
|
||||
var b [16]byte
|
||||
if _, err := rand.Read(b[:]); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(b[:]), nil
|
||||
}
|
||||
|
||||
//export SdsGoCallback
|
||||
func SdsGoCallback(ret C.int, msg *C.char, len C.size_t, resp unsafe.Pointer) {
|
||||
if resp != nil {
|
||||
@ -199,12 +210,17 @@ func NewReliabilityManager(logger *zap.Logger) (*ReliabilityManager, error) {
|
||||
|
||||
rm.logger.Info("creating new reliability manager")
|
||||
|
||||
// Empty participantId keeps plain SDS (causal history, acks, missing-deps)
|
||||
// and disables SDS-R repair — matching the pre-nim-ffi binding's behavior.
|
||||
createReq := sdsCreateReq{Config: sdsConfig{ParticipantID: ""}}
|
||||
// participantId is the per-manager SDS-R identity. A non-empty id enables
|
||||
// SDS-R (repair/retrieval); we generate a random one so each manager has a
|
||||
// distinct identity.
|
||||
participantID, err := randomParticipantID()
|
||||
if err != nil {
|
||||
return nil, errorspkg.Wrap(err, "failed to generate participant id")
|
||||
}
|
||||
createReq := sdsCreateReq{Config: sdsConfig{ParticipantID: participantID}}
|
||||
|
||||
var ret int
|
||||
err := withReqCbor(createReq, func(ptr unsafe.Pointer, length C.size_t) {
|
||||
err = withReqCbor(createReq, func(ptr unsafe.Pointer, length C.size_t) {
|
||||
var data []byte
|
||||
ret, data = sdsCall(func(resp unsafe.Pointer) {
|
||||
rm.rmCtx = C.cGoSdsCreate(ptr, length, resp)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user