pub struct CircuitBreaker { /* private fields */ }
Expand description
Circuit breaker implementation to prevent cascading failures
The circuit breaker tracks failures and “trips” after a threshold is reached, preventing further calls and allowing the system to recover.
Implementations§
Source§impl CircuitBreaker
impl CircuitBreaker
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new circuit breaker with the given name and default configuration
Sourcepub fn with_config(
name: impl Into<String>,
config: CircuitBreakerConfig,
) -> Self
pub fn with_config( name: impl Into<String>, config: CircuitBreakerConfig, ) -> Self
Create a new circuit breaker with custom configuration
Sourcepub fn state(&self) -> CircuitState
pub fn state(&self) -> CircuitState
Get the current state of the circuit breaker
Sourcepub fn execute<F, T, E>(&self, f: F) -> RecoveryResult<T>
pub fn execute<F, T, E>(&self, f: F) -> RecoveryResult<T>
Execute a function protected by the circuit breaker
Auto Trait Implementations§
impl Freeze for CircuitBreaker
impl RefUnwindSafe for CircuitBreaker
impl Send for CircuitBreaker
impl Sync for CircuitBreaker
impl Unpin for CircuitBreaker
impl UnwindSafe for CircuitBreaker
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