pub struct BreakerPolicy {
pub failures: Option<NonZeroU64>,
pub cooldown: DurationMs,
pub window: Option<DurationMs>,
pub failure_rate: Option<f64>,
pub min_calls: Option<NonZeroU32>,
}Expand description
breaker = { failures, cooldown, window, failure_rate, min_calls }.
Two modes per the frozen schema ($defs/breaker), enforced identically by
the real core and every stub — normative rules in conformance/README.md:
- count mode: selected when
failuresis set (or no rate knob is set;failuresthen defaults to 5) —failuresconsecutive terminal failures open the breaker. - rate mode: selected when
failuresis absent and bothwindowandfailure_rateare set — trips when the trailingwindowholds at leastmin_callsoutcomes (default 10) withfailed/total >= failure_rate.
A rate-mode knob without both window and failure_rate (and without
failures) is rejected at deserialize time (KEEL-E001): a half-configured
mode must fail loudly, never silently degrade to count-mode defaults.
Fields§
§failures: Option<NonZeroU64>Count-mode threshold. None means “not set by the user” — see
BreakerPolicy::mode for how that selects the mode.
cooldown: DurationMs§window: Option<DurationMs>§failure_rate: Option<f64>§min_calls: Option<NonZeroU32>Implementations§
Source§impl BreakerPolicy
impl BreakerPolicy
Sourcepub const DEFAULT_FAILURES: NonZeroU64
pub const DEFAULT_FAILURES: NonZeroU64
Schema default for count mode’s failures.
Sourcepub const DEFAULT_MIN_CALLS: NonZeroU32
pub const DEFAULT_MIN_CALLS: NonZeroU32
Schema default for rate mode’s min_calls.
Sourcepub fn mode(&self) -> BreakerMode
pub fn mode(&self) -> BreakerMode
The mode this policy selects (schema: “Setting failures selects count
mode”), with defaults applied. Deserialization already rejected
half-configured rate mode, so window+failure_rate are either both
present or irrelevant here.
Sourcepub fn has_inert_rate_knobs(&self) -> bool
pub fn has_inert_rate_knobs(&self) -> bool
Whether count mode was selected while rate-mode knobs are present — those knobs are inert (the schema’s precedence), which callers may want to surface loudly rather than leave silent.
Trait Implementations§
Source§impl Clone for BreakerPolicy
impl Clone for BreakerPolicy
Source§fn clone(&self) -> BreakerPolicy
fn clone(&self) -> BreakerPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more