pub struct CircuitBreakerConfig {
pub failure_threshold: u32,
pub success_threshold: u32,
pub error_rate_threshold: f64,
pub window_secs: u64,
pub open_cooldown_secs: u64,
pub half_open_max_probes: u32,
pub command_failure_threshold: u32,
pub open_cooldown_max_secs: u64,
}Expand description
Circuit breaker configuration.
Fields§
§failure_threshold: u32Consecutive failures to open circuit.
success_threshold: u32Consecutive successes to close circuit.
error_rate_threshold: f64Error rate threshold (0.0-1.0) to open circuit.
window_secs: u64Rolling window size in seconds.
open_cooldown_secs: u64Cooldown duration before half-open (seconds).
half_open_max_probes: u32Max concurrent probes in half-open.
command_failure_threshold: u32Consecutive command-class failures to open the circuit.
Command-class evidence is an operation of the same shape as dispatched
work — a remote binary that must run to completion (the telemetry poll,
or a health probe whose session connected but whose command never
finished). It is tracked separately from the plain liveness probe
because a host under fork exhaustion or swap thrash keeps answering
echo over a warm connection while every real command times out;
interleaved liveness successes would otherwise keep resetting
failure_threshold and the breaker would never trip.
open_cooldown_max_secs: u64Upper bound (seconds) for the open cooldown after repeated reopens.
Each Open -> HalfOpen -> Open cycle without an intervening Closed
doubles the cooldown (open_cooldown_secs, x2, x4, …) up to this
cap, so a flapping worker converges to Open instead of being
re-admitted every cooldown. Set equal to open_cooldown_secs to
disable the backoff.
Implementations§
Source§impl CircuitBreakerConfig
impl CircuitBreakerConfig
Sourcepub fn cooldown_ms_for_streak(&self, reopen_streak: u32) -> u64
pub fn cooldown_ms_for_streak(&self, reopen_streak: u32) -> u64
Effective cooldown (ms) for the given reopen streak, with exponential
backoff capped at open_cooldown_max_secs. reopen_streak counts
Open transitions since the circuit last closed (1 = first open).