Let a holder take asks once over a store bound on its own link

process.StateOver gives a State over a key-value store the caller bound
itself, so the node-engine, which serves its seat over its own link, keeps
the asks it took in its own taken state.

Builds: design 47 H2 §775; H-A-364
This commit is contained in:
2026-11-21 23:19:11 +01:00
parent 6852228000
commit 0c27544582
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -399,6 +399,13 @@ func (s State) delete(key string) error {
return nil
}
// StateOver is a module's state read and written through kv, a key-value store bound over a link of the caller's own
// rather than a Conn (H-A-364): the node-engine, which serves its seat over its own link, takes asks once on its own
// taken state with it. module and name name it in errors.
func StateOver(module, name string, kv jetstream.KeyValue) *State {
return &State{Module: module, Name: name, kv: func(context.Context) (jetstream.KeyValue, error) { return kv, nil }}
}
// TakenState is the state a holder of a kept call keeps the ids of the asks it took in: stdio.TakenState.
const TakenState = stdio.TakenState
+1 -1
View File
@@ -230,7 +230,7 @@ func TestStatePutWritesAKeyWhole(t *testing.T) {
// Design 47 H2 §775: a holder given the same ask id twice acts once; the id is kept under <seat>.<ask> with the
// ask's bound as its time to live; an ask with no id, or one that is not one key, is refused.
tkv := newFakeKV()
taken := stateOn(tkv)
taken := StateOver("mesh-host", TakenState, tkv) // H-A-364: over a store the caller bound itself
acts := 0
for range 2 {
if first, err := taken.TakeOnce("mesh-builds", "a-7", 10*time.Minute); err != nil {