#[non_exhaustive]pub struct CircuitBreakerConfig {
pub failure_threshold: usize,
pub failure_window_ms: u64,
pub reset_timeout_ms: u64,
}Expand description
Configuration for a circuit breaker.
Marked #[non_exhaustive] so future minor releases can add new
tuning knobs without breaking callers. Construct via
CircuitBreakerConfig::default then mutate the fields you
care about.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.failure_threshold: usizeNumber of failures required to open the circuit
failure_window_ms: u64Time window in milliseconds to count failures
reset_timeout_ms: u64Time in milliseconds that the circuit stays open before trying again
Implementations§
Source§impl CircuitBreakerConfig
impl CircuitBreakerConfig
Sourcepub fn new(
failure_threshold: usize,
failure_window_ms: u64,
reset_timeout_ms: u64,
) -> Self
pub fn new( failure_threshold: usize, failure_window_ms: u64, reset_timeout_ms: u64, ) -> Self
Construct a CircuitBreakerConfig from its three core knobs.
Provided so external callers (tests, custom circuit-breaker
wiring) can build the struct without depending on its field
list, which may grow over the 1.x line. For tuning only a
subset, start from Self::default and use the
with_* builder methods.
Sourcepub fn with_failure_threshold(self, threshold: usize) -> Self
pub fn with_failure_threshold(self, threshold: usize) -> Self
Override the failure-count threshold.
Sourcepub fn with_failure_window_ms(self, window_ms: u64) -> Self
pub fn with_failure_window_ms(self, window_ms: u64) -> Self
Override the failure-counting window in milliseconds.
Sourcepub fn with_reset_timeout_ms(self, reset_ms: u64) -> Self
pub fn with_reset_timeout_ms(self, reset_ms: u64) -> Self
Override the reset-timeout in milliseconds.
Trait Implementations§
Source§impl Clone for CircuitBreakerConfig
impl Clone for CircuitBreakerConfig
Source§fn clone(&self) -> CircuitBreakerConfig
fn clone(&self) -> CircuitBreakerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more