pub struct CircuitBreaker { /* private fields */ }Expand description
Circuit breaker for a module.
Implementations§
Source§impl CircuitBreaker
impl CircuitBreaker
Sourcepub fn new(module_name: String, config: CircuitConfig) -> Self
pub fn new(module_name: String, config: CircuitConfig) -> Self
Creates a new circuit breaker.
Sourcepub fn with_defaults(module_name: String) -> Self
pub fn with_defaults(module_name: String) -> Self
Creates a circuit breaker with default configuration.
Sourcepub fn can_execute(&self) -> bool
pub fn can_execute(&self) -> bool
Checks if a request can proceed.
Sourcepub fn record_success(&self)
pub fn record_success(&self)
Records a successful call.
Sourcepub fn record_failure(&self)
pub fn record_failure(&self)
Records a failed call.
Sourcepub fn state(&self) -> CircuitState
pub fn state(&self) -> CircuitState
Returns the current state.
Sourcepub fn stats(&self) -> CircuitStats
pub fn stats(&self) -> CircuitStats
Returns statistics.
Sourcepub fn module_name(&self) -> &str
pub fn module_name(&self) -> &str
Returns the module name.
Sourcepub fn force_open(&self)
pub fn force_open(&self)
Forces the circuit to open (for testing/manual intervention).
Sourcepub fn force_close(&self)
pub fn force_close(&self)
Forces the circuit to close (for testing/manual intervention).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CircuitBreaker
impl RefUnwindSafe for CircuitBreaker
impl Send for CircuitBreaker
impl Sync for CircuitBreaker
impl Unpin for CircuitBreaker
impl UnsafeUnpin 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