pub struct PassiveHealthChecker { /* private fields */ }Expand description
Tracks 5xx responses per backend and temporarily marks backends unhealthy when they exceed a failure threshold within a sliding time window. After a cooldown period the backend is automatically re-enabled.
Implementations§
Source§impl PassiveHealthChecker
impl PassiveHealthChecker
Sourcepub fn new(n: usize, config: &PassiveHealthConfig) -> Self
pub fn new(n: usize, config: &PassiveHealthConfig) -> Self
Create a new passive health tracker for n backends.
Sourcepub async fn record_failure(&self, idx: usize, pool: &UpstreamPool)
pub async fn record_failure(&self, idx: usize, pool: &UpstreamPool)
Record a 5xx failure for backend idx. If the number of failures in
the configured window exceeds max_fails, the backend is disabled.
Sourcepub async fn maybe_recover(&self, pool: &UpstreamPool)
pub async fn maybe_recover(&self, pool: &UpstreamPool)
Check whether any previously-disabled backend should be re-enabled after the cooldown period. Call this periodically (e.g. after each request or on a timer).
Sourcepub fn is_disabled(&self, idx: usize) -> bool
pub fn is_disabled(&self, idx: usize) -> bool
Returns true if the backend is currently passively disabled.
Auto Trait Implementations§
impl Freeze for PassiveHealthChecker
impl !RefUnwindSafe for PassiveHealthChecker
impl Send for PassiveHealthChecker
impl Sync for PassiveHealthChecker
impl Unpin for PassiveHealthChecker
impl UnsafeUnpin for PassiveHealthChecker
impl !UnwindSafe for PassiveHealthChecker
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
Mutably borrows from an owned value. Read more