pub struct CircuitBreakerConfig {
pub failure_threshold: u32,
pub success_threshold: u32,
pub open_duration: Duration,
}Expand description
Configuration for the circuit breaker pattern.
The circuit breaker monitors failures and temporarily stops sending requests to a failing service, giving it time to recover.
§States
- Closed — Normal operation. Failures are counted; when
failure_thresholdconsecutive failures occur, the circuit opens. - Open — All calls are rejected with
CamelError::CircuitOpen. Afteropen_durationelapses, the circuit transitions to half-open. - Half-Open — A single probe call is allowed through. If it succeeds
(
success_thresholdtimes), the circuit closes. If it fails, the circuit reopens.
Fields§
§failure_threshold: u32Number of consecutive failures before opening the circuit.
success_threshold: u32Number of successful probes in half-open state before closing.
Current limitation: Only 1 is effectively supported. The state
machine resets to Closed on the first successful half-open probe
regardless of this value. Multi-probe half-open tracking is deferred.
open_duration: DurationHow long the circuit stays open before allowing a probe.
Implementations§
Source§impl CircuitBreakerConfig
impl CircuitBreakerConfig
pub fn new() -> Self
pub fn failure_threshold(self, n: u32) -> Self
pub fn open_duration(self, duration: Duration) -> Self
Trait Implementations§
Source§impl Clone for CircuitBreakerConfig
impl Clone for CircuitBreakerConfig
Source§fn clone(&self) -> CircuitBreakerConfig
fn clone(&self) -> CircuitBreakerConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CircuitBreakerConfig
impl Debug for CircuitBreakerConfig
Auto Trait Implementations§
impl Freeze for CircuitBreakerConfig
impl RefUnwindSafe for CircuitBreakerConfig
impl Send for CircuitBreakerConfig
impl Sync for CircuitBreakerConfig
impl Unpin for CircuitBreakerConfig
impl UnsafeUnpin for CircuitBreakerConfig
impl UnwindSafe for CircuitBreakerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more