S3 away: read a holder's answer of the kind away as a transport fault

A holder answers error-kind away, with part and words, when a part it
depends on is away; the kept call reads it from the answer and calls again
at the pace. Go: busretry.ErrorKindAway, AwayAnswer, AwayIn, Away;
TypeScript: ERROR_KIND_AWAY, awayAnswer, awayIn.

Builds: design 47 H2 §776, §775; H-A-349 DQ-15, H-A-350 DMC-2, H-A-354
This commit is contained in:
2026-11-21 23:10:27 +01:00
parent d40fa0b3a0
commit 423de0e8a2
6 changed files with 126 additions and 4 deletions
+11 -1
View File
@@ -123,7 +123,17 @@ func keptOf(key string, ask KeptAsk, open *busretry.Open) busretry.Kept {
// callKeptWith is callWith for a kept call: busretry.DoPaced with no blackout probe.
func callKeptWith(k busretry.Kept, request func(string, []byte) (json.RawMessage, error), called, fallback string,
data []byte) (json.RawMessage, error) {
return busretry.DoPaced(k, askBoth(request, called, fallback, data))
ask := askBoth(request, called, fallback, data)
return busretry.DoPaced(k, func() (json.RawMessage, error) {
result, err := ask()
if err == nil {
// A holder's answer of the kind away is a transport fault (§776): called again at the pace.
if away := busretry.AwayIn(result); away != nil {
return result, away
}
}
return result, err
})
}
// askBoth asks called, then fallback when nothing answers it.
+21
View File
@@ -138,6 +138,27 @@ func TestACallIsAskedAgainOnlyWhenItReachedNoOne(t *testing.T) {
t.Errorf("%s: asked %d times (%v), want %d", row.name, asks, err, row.asks)
}
}
// Design 47 H2 §776: a holder's answer of the kind away is a transport fault, called again at the pace; a refusal
// of another kind is the caller's answer at once.
for _, row := range []struct {
name string
answers []string
asks int
}{
{"away, then answered", []string{`{"error":"x","error-kind":"away","part":"the forge's store","words":"401"}`, `{"merged":true}`}, 2},
{"refused: answered at once", []string{`{"error":"no","error-kind":"refused"}`}, 1},
} {
asks := 0
request := func(string, []byte) (json.RawMessage, error) {
a := row.answers[min(asks, len(row.answers)-1)]
asks++
return json.RawMessage(a), nil
}
got, err := callKeptWith(busretry.Kept{Seat: "git", Verb: "merge-pull"}, request, "called", "fallback", nil)
if asks != row.asks || err != nil || string(got) != row.answers[len(row.answers)-1] {
t.Errorf("%s: asked %d times, %s, %v", row.name, asks, got, err)
}
}
// Design 47 H2 §775, H-A-351: a kept call carries its ask's id in the header, and a holder in a process reads it with
// AskOf while its handler runs; a call carrying none reads empty.
if m := askMsg("mesh.seat.mesh-builds.call.build", []byte(`{}`), "ask-9"); m.Header.Get(stdio.AskHeader) != "ask-9" {