Files
mesh-delivery/modules/mesh-delivery-sdk/steprun/again.go
T
jschoubben f6e7f4210b B9: a fetch or a publish met away ends its run again, by again-delays, with no seat call
The build modules' shared steprun parts of §799: again-delays (15s,60s) read
into a Puller's Delay; a fetch's 401/5xx or connection fault and a publish's
no responders or exited bundle are transport faults whose why opens fetch: or
publish:; the assigner call that named a silent holder goes. The builder reads
an exited bundle as no responders and keeps the part in a key's fault words.

Builds: design 47 H2 §799 (H-A-390)
2026-11-22 00:20:17 +01:00

42 lines
1.4 KiB
Go

package steprun
import (
"fmt"
"strings"
"time"
)
// AgainDelaysSetting is the setting each build module declares for the delay it passes with a run's `again` (design 47
// H2 §799): how long the bus waits before it gives an ask again after its first, then its second run ended on a
// transport fault, as Go durations separated by commas. DefaultAgainDelays is its default, so three runs span a
// one-minute absence of a holder.
const (
AgainDelaysSetting = "again-delays"
DefaultAgainDelays = "15s,60s"
)
// AgainDelays reads the setting again-delays into a Puller's Delay (§799): the run-th delay of the list, its last for a
// run past it; an empty setting is DefaultAgainDelays. A delay that is no positive duration is an error naming it.
func AgainDelays(setting string) (func(run int) time.Duration, error) {
if strings.TrimSpace(setting) == "" {
setting = DefaultAgainDelays
}
var delays []time.Duration
for _, w := range strings.Split(setting, ",") {
d, err := time.ParseDuration(strings.TrimSpace(w))
if err != nil || d <= 0 {
return nil, fmt.Errorf("the setting %s holds %q, whose %q is not a positive duration", AgainDelaysSetting, setting, w)
}
delays = append(delays, d)
}
return func(run int) time.Duration {
if run < 1 {
run = 1
}
return delays[min(run, len(delays))-1]
}, nil
}
// defaultAgainDelay is DefaultAgainDelays read, a Puller's delay when it names none.
var defaultAgainDelay, _ = AgainDelays(DefaultAgainDelays)