pub struct CircuitBreakerWrapper { /* private fields */ }Expand description
Thread-safe circuit breaker that tracks failures and short-circuits calls when a provider is unhealthy.
State transitions: Closed -> (failures >= threshold) -> Open -> (wait period elapsed) -> HalfOpen -> (probe succeeds) -> Closed (or probe fails -> back to Open).
Implementations§
Source§impl CircuitBreakerWrapper
impl CircuitBreakerWrapper
Sourcepub fn new(config: CircuitBreakerConfig) -> Self
pub fn new(config: CircuitBreakerConfig) -> Self
Create a new circuit breaker with the given configuration.
Sourcepub async fn call<F, Fut, T>(&self, f: F) -> Result<T>
pub async fn call<F, Fut, T>(&self, f: F) -> Result<T>
Execute f through the circuit breaker.
Returns RuntimeError::Unavailable immediately when the breaker is
open. In the half-open state only a single probe call is allowed;
concurrent callers receive Unavailable until the probe completes.
Trait Implementations§
Source§impl Clone for CircuitBreakerWrapper
impl Clone for CircuitBreakerWrapper
Source§fn clone(&self) -> CircuitBreakerWrapper
fn clone(&self) -> CircuitBreakerWrapper
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 CircuitBreakerWrapper
impl RefUnwindSafe for CircuitBreakerWrapper
impl Send for CircuitBreakerWrapper
impl Sync for CircuitBreakerWrapper
impl Unpin for CircuitBreakerWrapper
impl UnwindSafe for CircuitBreakerWrapper
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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