pub struct UpstreamInstance { /* private fields */ }Expand description
One backend instance (host:port) of an upstream, with its health state (ADR 000017).
The hot path (pick → UpstreamInstance::is_healthy) reads a lock-free AtomicBool. State
transitions take a small per-instance Mutex so “increment a counter, compare the threshold,
flip the bit, reset” is race-free — but the mutex is touched only on a probe (cold, every
interval) or a passive connect failure (rare), never on the success hot path.
Implementations§
Source§impl UpstreamInstance
impl UpstreamInstance
Sourcepub fn in_flight(&self) -> usize
pub fn in_flight(&self) -> usize
Current active forwarded-request count to this instance (ADR 000035) — the least-request load signal. Lock-free read.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Whether this instance is currently in rotation. Lock-free — the round-robin hot path.
Sourcepub fn is_outlier_ejected(&self, now_ms: u64) -> bool
pub fn is_outlier_ejected(&self, now_ms: u64) -> bool
Whether this instance is currently outlier-ejected at now_ms (ADR 000032). Lock-free — the
pick hot path. The ejection auto-expires when its window passes (no probe needed); this is a
distinct axis from is_healthy (an instance can be probe-healthy yet outlier-ejected).
Sourcepub fn record_probe_success(&self)
pub fn record_probe_success(&self)
Record a successful active probe (a 2xx within the timeout). Promotes a pessimistic / ejected
instance once it reaches its threshold — one success the first time ever, healthy_threshold
after a later eject — and resets the consecutive-failure streak.
Sourcepub fn record_probe_failure(&self)
pub fn record_probe_failure(&self)
Record a failed active probe (non-2xx, timeout, or connect error).
Sourcepub fn record_passive_failure(&self)
pub fn record_passive_failure(&self)
Record a passive failure — a real forwarded request that could not even connect to this instance (ADR 000017). It demotes exactly like a probe failure, but can only ever demote: an ejected instance receives no traffic, so only the active prober restores it.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UpstreamInstance
impl RefUnwindSafe for UpstreamInstance
impl Send for UpstreamInstance
impl Sync for UpstreamInstance
impl Unpin for UpstreamInstance
impl UnsafeUnpin for UpstreamInstance
impl UnwindSafe for UpstreamInstance
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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