process, stdio: a kept call paces on a stopping tool runner; the ask's bound is a setting (H-A-549)
Review round 1: the process caller read only a reply's error, so a kept call (CallKept, e.g. seat:git.trees) ended at once on stopping instead of pacing until the new runner answers. requestAsk now reads error-kind stopping as busretry.Stopping, which busretry.Fault counts as a transport fault, as away. The Go stdio Ask's 60 s bound becomes the setting ask-bound (default 60 s), read by the settings reader. Builds: design 47 H2 H-A-542, H-A-549
This commit is contained in:
+15
-5
@@ -189,6 +189,15 @@ func callWith(request func(string, []byte) (json.RawMessage, error), blackout fu
|
||||
return busretry.Do("the call on "+fallback, askBoth(request, called, fallback, data), blackout)
|
||||
}
|
||||
|
||||
// replyError is the error a reply naming one is the call's: a stopping tool runner's kind stopping is a transport fault a
|
||||
// kept call's pacing asks again on, as away is (design 47 H2 H-A-542, H-A-549); any other is the callee's answer.
|
||||
func replyError(words, kind string) error {
|
||||
if kind == busretry.ErrorKindStopping {
|
||||
return &busretry.Stopping{Words: words}
|
||||
}
|
||||
return answered(words)
|
||||
}
|
||||
|
||||
// answered is the error a callee answered with: delivered, never asked again (busretry.Answered).
|
||||
func answered(words string) error { return &busretry.Answered{Words: words} }
|
||||
|
||||
@@ -272,16 +281,17 @@ func (c *Conn) requestAsk(subject string, data []byte, ask string) (json.RawMess
|
||||
return nil, err
|
||||
}
|
||||
var r struct {
|
||||
Result json.RawMessage `json:"result"`
|
||||
Error string `json:"error"`
|
||||
Node string `json:"node"`
|
||||
Held *approval.Held `json:"held"`
|
||||
Result json.RawMessage `json:"result"`
|
||||
Error string `json:"error"`
|
||||
ErrorKind string `json:"error-kind"`
|
||||
Node string `json:"node"`
|
||||
Held *approval.Held `json:"held"`
|
||||
}
|
||||
if err := json.Unmarshal(msg.Data, &r); err != nil {
|
||||
return nil, fmt.Errorf("%s answered something that is not a seat's answer: %w", subject, err)
|
||||
}
|
||||
if r.Error != "" {
|
||||
return nil, answered(r.Error)
|
||||
return nil, replyError(r.Error, r.ErrorKind)
|
||||
}
|
||||
if r.Held != nil {
|
||||
return c.awaitGated(subject, *r.Held)
|
||||
|
||||
@@ -142,20 +142,25 @@ 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.
|
||||
// Design 47 H2 §776: a holder's answer of the kind away is a transport fault, called again at the pace; so is a
|
||||
// stopping tool runner's reply of the kind stopping (H-A-542, H-A-549); 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},
|
||||
{"stopping, then answered by the new runner", []string{"stopping", `{"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++
|
||||
if a == "stopping" {
|
||||
return nil, replyError("git's trees was not taken: the tool runner is stopping", "stopping")
|
||||
}
|
||||
return json.RawMessage(a), nil
|
||||
}
|
||||
got, err := callKeptWith(busretry.Kept{Seat: "git", Verb: "merge-pull"}, request, "called", "fallback", nil)
|
||||
|
||||
Reference in New Issue
Block a user