carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package moves
2
3// The probe's attempt policy (moves spec §7.7, R12-2, INV-19).
4//
5// The window itself is not restated here. The activator's probeWindow and
6// start loop (internal/activator/claimwindow.go, claimwake.go) already
7// enforce the 30 second window counted from the attempt's first start, the
8// absolute cut deadline before every start and before readiness is
9// accepted, at most five starts and the doubling backoff between them. This
10// file holds the one piece of policy that lives with the moves: how many
11// attempts a probe is given. The per-attempt cost that prices them is
12// budget.go's, and ProbeAttemptsMax is its ceiling.
13
14// RecoveryAttempts is the number of probe attempts a recovery install is
15// given (§7.7): three rounds of the landing's three, because a recovery has
16// nowhere further to fall back to.
17const RecoveryAttempts = 9
18
19// Probe kinds, as the operation kinds the claim records.
20const (
21 ProbeLanding = "landing"
22 ProbeRecovery = "recovery"
23)
24
25// AttemptsFor is how many probe attempts a probe of the given kind may
26// make. A landing gets the attempts T11 admitted (budget.go
27// AttemptsAdmitted), at most ProbeAttemptsMax, and none when none were
28// admitted. A recovery gets RecoveryAttempts whatever was admitted. A kind
29// that is neither gets none.
30func AttemptsFor(kind string, admitted int) int {
31 switch kind {
32 case ProbeLanding:
33 return max(0, min(ProbeAttemptsMax, admitted))
34 case ProbeRecovery:
35 return RecoveryAttempts
36 }
37 return 0
38}
39