diff --git a/go/process/call.go b/go/process/call.go index 1f5721af..59d1d850 100644 --- a/go/process/call.go +++ b/go/process/call.go @@ -67,10 +67,13 @@ func (c *Conn) CallKeptOn(node, key string, body any) (json.RawMessage, error) { } // KeptAsk is what a caller names of its kept call (design 47 H2 §775): the ask's id, which the call carries in the -// header stdio.AskHeader for the holder to take it once by (H-A-351), and the caller's bound (zero is busretry.Bound). +// header stdio.AskHeader for the holder to take it once by (H-A-351), the caller's bound (zero is busretry.Bound), and its +// hook (nil gives none): told when the call has waited busretry.WaitSaid and once at its answer, as busretry.Kept's is +// (design 47 H2 H-A-708 (4), H-A-731). type KeptAsk struct { ID string Bound time.Duration + Hook func(busretry.Waited) } // CallKeptAsk is CallKept carrying ask's id and stopping at ask's bound: past it the error is a *busretry.Unanswered @@ -110,7 +113,7 @@ func (c *Conn) callKeptAskOn(ask KeptAsk, node, key string, body any, open *busr // keptOf is the paced form's naming of a call on key: its seat and verb, or its module and tool. func keptOf(key string, ask KeptAsk, open *busretry.Open) busretry.Kept { - k := busretry.Kept{Ask: ask.ID, Bound: ask.Bound, Open: open} + k := busretry.Kept{Ask: ask.ID, Bound: ask.Bound, Open: open, Hook: ask.Hook} if a, err := calladdress.Parse(key); err == nil { k.Seat, k.Verb = a.Seat, a.Verb if a.Seat == "" { diff --git a/go/process/call_test.go b/go/process/call_test.go index 2e50f44c..162d0a34 100644 --- a/go/process/call_test.go +++ b/go/process/call_test.go @@ -227,6 +227,16 @@ func TestACallIsAskedAgainOnlyWhenItReachedNoOne(t *testing.T) { t.Errorf("%v answered %s", row.err, body) } } + // Design 47 H2 H-A-731: the hook a caller gives on its KeptAsk reaches the kept-call form, and a caller giving none gives none. + var hooked []busretry.Waited + k := keptOf("seat:mesh-catalog.revision", KeptAsk{ID: "ask-3", Hook: func(w busretry.Waited) { hooked = append(hooked, w) }}, nil) + if k.Hook == nil || k.Seat != "mesh-catalog" || k.Verb != "revision" || k.Ask != "ask-3" { + t.Fatalf("keptOf gave %+v", k) + } + k.Hook(busretry.Waited{Seat: k.Seat, Verb: k.Verb, Ask: k.Ask, Answered: true}) + if len(hooked) != 1 || !hooked[0].Answered || keptOf("seat:mesh-catalog.revision", KeptAsk{}, nil).Hook != nil { + t.Errorf("the hook on KeptAsk: told %+v", hooked) + } // Design 47 H2 §775, H-A-405: a kept chunked call (CallChunksKept, CallFileKept) asks its verb through the kept-call // form, carries its one ask id on every chunk's acknowledgement, and past its bound ends with the kept call's words. send := buscalls.SeatChunks{Seat: "node-build-go", Verb: "output", Call: "c1"}