pub struct EndpointHealth { /* private fields */ }Expand description
Per-endpoint passive health tracker. All pick-path reads are atomic;
only the observation window takes a lock (report path). Share via Arc
from the balancer state; carried across rebuilds for unchanged
address:port.
Implementations§
Source§impl EndpointHealth
impl EndpointHealth
Sourcepub fn with_events(sink: EndpointEvents) -> Self
pub fn with_events(sink: EndpointEvents) -> Self
Fresh tracker with ejection/recovery events (DW-044); see the module docs.
Sourcepub fn acquire(&self, params: &HealthParams, now: u64) -> bool
pub fn acquire(&self, params: &HealthParams, now: u64) -> bool
Whether a pick may use this endpoint at now (Unix-epoch ms);
consumes one probe slot when the endpoint is half-open. Lock-free.
Side effects: an expired ejection transitions to half-open here
(the first pick after eject_ms re-arms the probe budget) — the
transition therefore happens lazily on traffic rather than on a
timer.
Sourcepub fn is_candidate(&self, params: &HealthParams, now: u64) -> bool
pub fn is_candidate(&self, params: &HealthParams, now: u64) -> bool
Whether a pick MAY consider this endpoint at now (Unix-epoch ms)
— non-consuming. The balancer’s candidate filter calls this for
every endpoint; the endpoint actually SELECTED then consumes a
half-open probe slot via EndpointHealth::consume_probe.
Consuming only at selection keeps a half-open attempt from
deadlocking: probe slots are never burned by picks that go
elsewhere. Side effect: an expired ejection transitions to
half-open here (the first traffic after eject_ms re-arms the
probe budget) — the transition happens lazily on traffic rather
than on a timer.
Sourcepub fn consume_probe(&self)
pub fn consume_probe(&self)
Consume one half-open probe slot for a pick that SELECTED this endpoint. Best-effort: if a concurrent pick took the last slot, this pick still proceeds (one extra request beyond the probe budget may reach a recovering endpoint; the next report re-synchronizes the tracker).
Sourcepub fn is_available(&self, now: u64) -> bool
pub fn is_available(&self, now: u64) -> bool
Whether the endpoint is currently available WITHOUT consuming a probe (observability; not the pick path).
Sourcepub fn ejections(&self) -> u64
pub fn ejections(&self) -> u64
Total times this tracker has ejected an endpoint (observability).
Sourcepub fn state_label(&self, now: u64) -> &'static str
pub fn state_label(&self, now: u64) -> &'static str
Human state label for observability surfaces (admin /health,
DW-022): healthy, ejected, or half_open. An ejection whose
window has expired but not yet transitioned reports half_open
(the next pick arms the probe budget), mirroring
Self::is_available’s view of expiry.
Sourcepub fn report(&self, params: &HealthParams, now: u64, is_failure: bool)
pub fn report(&self, params: &HealthParams, now: u64, is_failure: bool)
Report one observation for this endpoint at now (Unix-epoch ms):
is_failure = transport error or HTTP status >= 500 (see the
module docs for the 1xx-4xx policy). Applies the ejection rules
against params.
Sourcepub fn report_probe(&self, params: &HealthParams, now: u64, is_failure: bool)
pub fn report_probe(&self, params: &HealthParams, now: u64, is_failure: bool)
Report one ACTIVE (synthetic probe) observation at now (Unix-epoch
ms). Runs the same state machine as EndpointHealth::report —
the shared consecutive-failure streak and every ejection/recovery
transition — but the observation NEVER enters the rolling
failure-ratio window: that window is real traffic only, so probes
cannot contaminate the passive ratios (the ratio rule also stays
disabled by the caller’s parameters as a second line of defense).
Sourcepub fn recovered_at_ms(&self) -> u64
pub fn recovered_at_ms(&self) -> u64
REL-06 (#217): the Unix-epoch ms when the endpoint last recovered from ejection, or 0 if it was never ejected (or the ramp is disabled). Used by the load balancer to compute the recovery ramp weight multiplier.
Trait Implementations§
Source§impl Debug for EndpointHealth
impl Debug for EndpointHealth
Source§impl Default for EndpointHealth
impl Default for EndpointHealth
Source§fn default() -> EndpointHealth
fn default() -> EndpointHealth
Auto Trait Implementations§
impl !Freeze for EndpointHealth
impl RefUnwindSafe for EndpointHealth
impl Send for EndpointHealth
impl Sync for EndpointHealth
impl Unpin for EndpointHealth
impl UnwindSafe for EndpointHealth
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&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