Documentation
¶
Overview ¶
Package driver holds the two periodic-scan loop shapes, plus the timer and backoff primitives a wake-driven loop builds its own shape from. In both scan shapes a non-positive interval means the driver is off; a wake-driven loop says that some other way, since its intervals are floors rather than cadences.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Rearm ¶
Rearm resets t to fire d from now, for a wake-driven loop that re-arms one timer after every pass. Safe on a timer that is still running, one that has fired, and one whose value was never received: since Go 1.23 the timer channel is unbuffered, so Reset cannot leave a stale value behind.
Types ¶
type Backoff ¶
type Backoff struct {
Base time.Duration
Max time.Duration
// contains filtered or unexported fields
}
Backoff is the retry delay a wake-driven driver uses when a step fails: it doubles from Base and is capped at Max. A non-positive Max means no ceiling to grow toward, so the delay stays at Base rather than collapsing to zero. The zero value is unusable — Base must be positive.
func (*Backoff) Next ¶
Next returns the next delay and doubles it for the call after, saturating at Max.
It saturates rather than doubling past Max because the doubling overflows: 37 doublings of a 100ms base pass time.Duration's range, and a negative cur reads as uninitialized below — which would drop a driver back to Base part way through the outage the backoff exists for.