diff --git a/go/stateobjects/fakes_test.go b/go/stateobjects/fakes_test.go index b0a6a534..60c454da 100644 --- a/go/stateobjects/fakes_test.go +++ b/go/stateobjects/fakes_test.go @@ -192,6 +192,7 @@ func (m *memory) serve(method string, raw json.RawMessage) (any, error) { Revision uint64 `json:"revision"` Name string `json:"name"` Data []byte `json:"data"` + Object string `json:"object"` } _ = json.Unmarshal(raw, &p) switch method { @@ -214,6 +215,9 @@ func (m *memory) serve(method string, raw json.RawMessage) (any, error) { case buscalls.ObjectsGet: d, err := m.Object(p.Name) return buscalls.ObjectData{Info: buscalls.ObjectInfo{Name: p.Name}, Data: d}, err + case buscalls.ObjectsSentGet: + d, err := m.Object(p.Object) + return buscalls.ObjectData{Info: buscalls.ObjectInfo{Name: p.Object}, Data: d}, err case buscalls.ObjectsDelete: return buscalls.Done{}, memObjects{m}.Delete(p.Name) case buscalls.ObjectsList: diff --git a/go/stateobjects/send.go b/go/stateobjects/send.go new file mode 100644 index 00000000..6420a2ed --- /dev/null +++ b/go/stateobjects/send.go @@ -0,0 +1,93 @@ +package stateobjects + +import ( + "encoding/json" + "fmt" + + stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/buscalls" +) + +// MessageLimit is the most a message of the bus carries when the sender does not know its connection's own +// (`nc.MaxPayload()`), and MessageHeaderRoom what the headers and the subject take of it. +const ( + MessageLimit = 1 << 20 + MessageHeaderRoom = 8 << 10 +) + +// Sender sends the body of a verb's reply or an event: a body over the per-message limit is put in the sender's store of +// sent objects and its reference is sent instead (ADR 0666 §16). The store is the bus module's `_sent-objects`, +// granted to the sender alone and read by the callers its seat definition names and the consumers that declare the event; +// a sent object lives as long as that store's age, which is transport and not kept data. +type Sender struct { + // Objects is the sender's store of sent objects, and Store its name as a reader asks for it. + Objects Objects + Store string + // Limit is the connection's largest message; zero is MessageLimit. + Limit int +} + +// Send is what to send for body: the body itself when it fits, else the reference of the object it was put in as +// `