pub struct BreakerState {
unhealthy_count: u32,
healthy_count: u32,
trip_round: u32,
open_until: Option<Instant>,
}Expand description
State of one circuit breaker (shared by an api-breaker check/observe pair).
Fields§
§unhealthy_count: u32Consecutive unhealthy responses observed while closed.
healthy_count: u32Consecutive healthy responses observed while half-open.
trip_round: u32How many times the breaker has tripped in the current unhealthy spell, used to grow the cooldown.
open_until: Option<Instant>When the breaker is open, the instant it may move to half-open.
Implementations§
Source§impl BreakerState
impl BreakerState
Sourcepub fn allow(&mut self) -> bool
pub fn allow(&mut self) -> bool
Whether a request should be allowed through right now. When the open
window has elapsed the breaker becomes half-open (this call returns
true to let one probe through).
Sourcepub fn record_healthy(&mut self, healthy_threshold: u32)
pub fn record_healthy(&mut self, healthy_threshold: u32)
Records a healthy upstream response. After healthy_threshold
consecutive healthy responses the breaker fully closes.
Sourcepub fn record_unhealthy(
&mut self,
unhealthy_threshold: u32,
break_base_sec: u64,
max_breaker_sec: u64,
)
pub fn record_unhealthy( &mut self, unhealthy_threshold: u32, break_base_sec: u64, max_breaker_sec: u64, )
Records an unhealthy upstream response. After unhealthy_threshold
consecutive unhealthy responses the breaker opens for
min(max_breaker_sec, break_base_sec * 2^trip_round).
Trait Implementations§
Source§impl Default for BreakerState
impl Default for BreakerState
Source§fn default() -> BreakerState
fn default() -> BreakerState
Auto Trait Implementations§
impl Freeze for BreakerState
impl RefUnwindSafe for BreakerState
impl Send for BreakerState
impl Sync for BreakerState
impl Unpin for BreakerState
impl UnsafeUnpin for BreakerState
impl UnwindSafe for BreakerState
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§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>
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>
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