struct ProviderCircuit {
state: CircuitState,
consecutive_failures: u32,
last_failure_time: Option<Instant>,
failure_threshold: u32,
reset_timeout_secs: u64,
}Expand description
Internal state for a single provider’s circuit breaker.
Fields§
§state: CircuitState§consecutive_failures: u32§last_failure_time: Option<Instant>§failure_threshold: u32§reset_timeout_secs: u64Implementations§
Source§impl ProviderCircuit
impl ProviderCircuit
fn new(config: &CircuitBreakerConfig) -> Self
Sourcefn should_allow(&mut self) -> bool
fn should_allow(&mut self) -> bool
Checks if a request should be allowed through.
Sourcefn record_success(&mut self)
fn record_success(&mut self)
Records a successful request. Resets the circuit to Closed.
Sourcefn record_failure(&mut self)
fn record_failure(&mut self)
Records a failed request. May trip the circuit to Open.
Auto Trait Implementations§
impl Freeze for ProviderCircuit
impl RefUnwindSafe for ProviderCircuit
impl Send for ProviderCircuit
impl Sync for ProviderCircuit
impl Unpin for ProviderCircuit
impl UnwindSafe for ProviderCircuit
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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