pub struct RestartPolicy {
pub max_restarts: u32,
pub backoff: Duration,
pub max_backoff: Duration,
pub window: Duration,
}Expand description
Bounded restart policy for crash exits.
max_restarts is the number of replacement processes allowed after the
initial spawn WITHIN window. After that many crash restarts inside one
window the module enters ModuleState::Failed and the supervisor stops
the crash loop.
The budget is a RATE, not a lifetime total. It used to be a lifetime total,
and that only survived because crashes were rare: a module that crashed
three times across a week was disabled forever by crashes that had nothing
to do with each other. That stopped being survivable once modules began
exiting non-zero whenever the daemon’s connection to them drops, because
then every daemon-side connection drop spends a unit of the same budget and
one flappy hour permanently stops a healthy module. Restarts older than
window release their slot, so a module that crashed twice yesterday has a
full budget today, while a genuine crash loop – which is fast by
definition – still reaches the cap and stops.
Fields§
§max_restarts: u32§backoff: DurationBase delay before a crash replacement. The actual delay escalates with
the number of recent crash replacements and is capped by max_backoff.
max_backoff: DurationMaximum delay before a crash replacement.
window: DurationThe span max_restarts is counted over. Duration::ZERO makes the
budget effectively infinite (nothing is ever in-window), which is why
daemon config refuses window_secs: 0 rather than quietly accepting it.
Implementations§
Source§impl RestartPolicy
impl RestartPolicy
Sourcepub fn new(max_restarts: u32, backoff: Duration) -> Self
pub fn new(max_restarts: u32, backoff: Duration) -> Self
A policy with the default crash window. Callers that care about the
window say so with Self::with_window; the ones that do not are
asking for the standard rate limit, not for no limit.