pub struct AtomicCircuitBreaker {
pub state_val: AtomicU8,
/* private fields */
}Expand description
Thread-safe circuit breaker using atomic operations.
Fields§
§state_val: AtomicU8Implementations§
Source§impl AtomicCircuitBreaker
impl AtomicCircuitBreaker
Sourcepub fn new(config: CircuitBreakerConfig) -> Self
pub fn new(config: CircuitBreakerConfig) -> Self
Creates a new circuit breaker with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Creates a circuit breaker with default configuration.
Trait Implementations§
Source§impl CircuitBreaker for AtomicCircuitBreaker
impl CircuitBreaker for AtomicCircuitBreaker
Source§fn state(&self) -> CircuitState
fn state(&self) -> CircuitState
Returns the current circuit state.
Source§fn record_success(&self)
fn record_success(&self)
Records a successful operation.
Source§fn record_failure(&self)
fn record_failure(&self)
Records a failed operation.
Source§fn time_until_half_open(&self) -> Option<Duration>
fn time_until_half_open(&self) -> Option<Duration>
Returns the time until the circuit will transition to half-open.
Returns
None if the circuit is not open.Source§fn failure_count(&self) -> u32
fn failure_count(&self) -> u32
Returns the current failure count.
Source§fn allows_request(&self) -> bool
fn allows_request(&self) -> bool
Returns whether the circuit allows requests through.
Auto Trait Implementations§
impl !Freeze for AtomicCircuitBreaker
impl !RefUnwindSafe for AtomicCircuitBreaker
impl Send for AtomicCircuitBreaker
impl Sync for AtomicCircuitBreaker
impl Unpin for AtomicCircuitBreaker
impl UnsafeUnpin for AtomicCircuitBreaker
impl UnwindSafe for AtomicCircuitBreaker
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more