pub struct CircuitBreaker { /* private fields */ }Expand description
Circuit breaker for fault tolerance
Implementations§
Source§impl CircuitBreaker
impl CircuitBreaker
Sourcepub fn with_config(config: BreakerConfig) -> Self
pub fn with_config(config: BreakerConfig) -> Self
Create a new circuit breaker with configuration
Sourcepub async fn initialize(&mut self) -> Result<(), BreakerError>
pub async fn initialize(&mut self) -> Result<(), BreakerError>
Initialize the circuit breaker
Sourcepub async fn shutdown(&mut self) -> Result<(), BreakerError>
pub async fn shutdown(&mut self) -> Result<(), BreakerError>
Shutdown the circuit breaker
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the system is initialized
Sourcepub async fn can_execute(&self) -> Result<bool, BreakerError>
pub async fn can_execute(&self) -> Result<bool, BreakerError>
Check if the circuit breaker allows execution
Sourcepub async fn execute<F, T, E>(&self, operation: F) -> Result<T, BreakerError>
pub async fn execute<F, T, E>(&self, operation: F) -> Result<T, BreakerError>
Execute an operation through the circuit breaker
Sourcepub async fn record_success(&self) -> Result<(), BreakerError>
pub async fn record_success(&self) -> Result<(), BreakerError>
Record a successful operation
Sourcepub async fn record_failure(&self) -> Result<(), BreakerError>
pub async fn record_failure(&self) -> Result<(), BreakerError>
Record a failed operation
Sourcepub async fn get_state(&self) -> CircuitState
pub async fn get_state(&self) -> CircuitState
Get the current circuit breaker state
Sourcepub async fn get_status(&self) -> Result<CircuitBreakerStatus, BreakerError>
pub async fn get_status(&self) -> Result<CircuitBreakerStatus, BreakerError>
Get circuit breaker status
Sourcepub async fn reset(&self) -> Result<(), BreakerError>
pub async fn reset(&self) -> Result<(), BreakerError>
Reset the circuit breaker
Trait Implementations§
Source§impl Clone for CircuitBreaker
impl Clone for CircuitBreaker
Source§fn clone(&self) -> CircuitBreaker
fn clone(&self) -> CircuitBreaker
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 moreAuto 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