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:
+17
-7
@@ -170,7 +170,7 @@ func (r *refused) ErrorKind() string { return r.kind }
|
||||
|
||||
// ErrorKindStopping is the typed fault a stopping tool runner answers each call it does not take with (design 47 H2 H-A-542):
|
||||
// the answer's `error-kind`. Ask asks again after a pause until the new runner answers or its bound ends.
|
||||
const ErrorKindStopping = "stopping"
|
||||
const ErrorKindStopping = busretry.ErrorKindStopping
|
||||
|
||||
// ErrStopping is a call a stopping tool runner did not take (ErrorKindStopping): nothing was done, and the new runner answers
|
||||
// it. Told apart by its kind, never by its words.
|
||||
@@ -604,7 +604,12 @@ func Ask(key string, body any) (json.RawMessage, error) {
|
||||
return nil, err
|
||||
}
|
||||
// A call a stopping tool runner did not take is asked again after a pause, at the kept-call pace, until the new runner
|
||||
// answers or Ask's own bound ends; then its fault is the caller's as such, ErrStopping (design 47 H2 H-A-542).
|
||||
// answers or Ask's own bound (the setting ask-bound) ends; then its fault is the caller's as such, ErrStopping (design 47 H2
|
||||
// H-A-542, H-A-549).
|
||||
askBound, err := SettingDuration(AskBoundSetting, DefaultAskBound)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
start, wait := askNow(), busretry.KeptPace().First
|
||||
for {
|
||||
left := askBound - askNow().Sub(start)
|
||||
@@ -621,12 +626,17 @@ func Ask(key string, body any) (json.RawMessage, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// askBound is how long Ask waits for its answer, asks again included; pause is how it waits between two asks and askNow its
|
||||
// clock, a test's to replace so nothing sleeps.
|
||||
// AskBoundSetting is the module's setting of how long Ask waits for its answer, asks again included, a duration text;
|
||||
// DefaultAskBound is its default (design 47 H2 H-A-549).
|
||||
const (
|
||||
AskBoundSetting = "ask-bound"
|
||||
DefaultAskBound = 60 * time.Second
|
||||
)
|
||||
|
||||
// pause is how Ask waits between two asks and askNow its clock, a test's to replace so nothing sleeps.
|
||||
var (
|
||||
askBound = 60 * time.Second
|
||||
pause = time.Sleep
|
||||
askNow = time.Now
|
||||
pause = time.Sleep
|
||||
askNow = time.Now
|
||||
)
|
||||
|
||||
// TopicMatches says whether an event's type matches a pattern: `*` is one dot-separated segment, `#`
|
||||
|
||||
Reference in New Issue
Block a user