S9 kept-call-hook: process.KeptAsk gains the hook and keptOf hands it on
Builds: design 47 H2 H-A-708 (4), H-A-731
This commit is contained in:
+5
-2
@@ -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
|
// 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 {
|
type KeptAsk struct {
|
||||||
ID string
|
ID string
|
||||||
Bound time.Duration
|
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
|
// 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.
|
// 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 {
|
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 {
|
if a, err := calladdress.Parse(key); err == nil {
|
||||||
k.Seat, k.Verb = a.Seat, a.Verb
|
k.Seat, k.Verb = a.Seat, a.Verb
|
||||||
if a.Seat == "" {
|
if a.Seat == "" {
|
||||||
|
|||||||
@@ -227,6 +227,16 @@ func TestACallIsAskedAgainOnlyWhenItReachedNoOne(t *testing.T) {
|
|||||||
t.Errorf("%v answered %s", row.err, body)
|
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
|
// 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.
|
// 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"}
|
send := buscalls.SeatChunks{Seat: "node-build-go", Verb: "output", Call: "c1"}
|
||||||
|
|||||||
Reference in New Issue
Block a user