From 0c275445826d5b53419ae4fc9c4351db5c400d18 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 23:19:11 +0100 Subject: [PATCH] Let a holder take asks once over a store bound on its own link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- go/process/state.go | 7 +++++++ go/process/state_test.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/go/process/state.go b/go/process/state.go index 5bd306af..6be76193 100644 --- a/go/process/state.go +++ b/go/process/state.go @@ -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 diff --git a/go/process/state_test.go b/go/process/state_test.go index 5f2321e4..76733752 100644 --- a/go/process/state_test.go +++ b/go/process/state_test.go @@ -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 . 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 {