Skip to main content

UpstreamGroup

Struct UpstreamGroup 

Source
pub struct UpstreamGroup {
    pub name: String,
    pub health: HealthConfig,
    /* private fields */
}
Expand description

A named upstream: its endpoint set, the round-robin cursor, and the health policy (ADR 000017).

Fields§

§name: String

The upstream name routes refer to.

§health: HealthConfig

The active-health-check policy (the prober reads path / interval_ms / timeout_ms).

Implementations§

Source§

impl UpstreamGroup

Source

pub fn try_acquire(self: &Arc<Self>) -> Option<RequestPermit>

Try to take an in-flight slot under the circuit-breaker cap (ADR 000028). None means the upstream is at max_requests and the fast path should fail closed (503). An unlimited breaker (max_requests == 0, the default) always succeeds with a zero-cost no-op permit. Lock-free: an optimistic increment that backs out if it crossed the cap, so concurrent callers never hold more than max_requests permits at once.

Source§

impl UpstreamGroup

Source

pub fn pick(&self, key: Option<HashInput<'_>>) -> Option<Pick>

Pick an instance per the upstream’s LB algorithm (ADR 000035), or None when nothing is eligible (the fast path then fails closed 503 — ADR 000017). key is the request’s hash key for maglev; round-robin / least-request ignore it, and None (no key) falls back to round-robin.

Source

pub fn pick_excluding( &self, exclude: &Arc<UpstreamInstance>, key: Option<HashInput<'_>>, ) -> Option<Pick>

Pick an instance OTHER than exclude, to retry a failed forward on a different instance (ADR 000023). Same algorithm dispatch as pick; for maglev the affinity target is excluded, so it falls back to round-robin over the remaining eligible set.

Source

pub fn has_eligible(&self) -> bool

Whether this upstream has at least one eligible instance (healthy and not outlier-ejected). A cursor-free, allocation-free probe the weighted traffic split (ADR 000034) uses to skip a backend whose group can serve nothing (renormalize over healthy). Same eligibility as the pick path minus the retry exclude; a false here means a pick would return None.

Source§

impl UpstreamGroup

Source

pub fn record_outcome( &self, instance: &Arc<UpstreamInstance>, gateway_failure: bool, ) -> bool

Record one forward’s outcome against instance for outlier detection (ADR 000032). gateway_failure is true only for a gateway-class 5xx (502/503/504) the upstream actually RETURNED — never a circuit-breaker shed or a per-try timeout (those are other axes). Returns true iff this call ejected the instance (the caller bumps the ejection metric). A success resets the failure streak and ejection backoff; consecutive failures past the threshold eject the instance for a backing-off window — unless that would push the pool past max_ejection_percent, in which case it stays in rotation (fail-closed must not self-DoS).

Source§

impl UpstreamGroup

Source

pub fn request_timeout(&self) -> Duration

The PER-TRY timeout the fast path applies to one forward attempt (ADR 000019, per-try by ADR 000031). Duration::ZERO means no per-try bound (e.g. a streaming / long-poll backend); otherwise one attempt is bounded and overrun fails closed 504.

Source

pub fn overall_timeout(&self) -> Duration

The OVERALL request deadline across all attempts + backoff (ADR 000031); Duration::ZERO means no overall bound (only the per-try request_timeout applies). Exceeding it fails closed 504 request-timeout with no further retry.

Source

pub fn max_retries(&self) -> u64

The max number of retries to a different instance on a retryable forward failure (ADR 000023); 0 disables retry.

Source

pub fn hash_key_source(&self) -> Option<&HashKeySource>

The hash-key source for a maglev upstream (ADR 000035), or None for the other algorithms. The fast path reads this to project a HashInput from the request.

Source

pub fn scheme(&self) -> &'static str

The scheme the fast path forwards (and health-probes) this upstream with (ADR 000042): https when [upstream.tls] is declared, else http.

Source

pub fn tls_client_config(&self) -> Option<&Arc<ClientConfig>>

The rustls client config for this upstream’s TLS forward leg (ADR 000042), or None for plain HTTP/1.1. The Arc is stable across reloads while [upstream.tls] is unchanged, so the fast path can key its per-config connection pool on the Arc’s identity.

Source

pub fn tls_sni(&self) -> Option<&ServerName<'static>>

The [upstream.tls] sni verification-name override (ADR 000050), or None when the fast path should derive the SNI / verification name from the connected address (the pre-000050 behaviour).

Source

pub fn endpoints(&self) -> Arc<Endpoints>

A snapshot of the current endpoint set (instances + LB state). One atomic load; the returned Arc stays valid across a concurrent re-resolution swap.

Source

pub fn resolve_interval(&self) -> Option<Duration>

How often the fast path should re-resolve this group’s hostname addresses, or None when re-resolution is off (the default).

Source

pub fn configured_addresses(&self) -> &[(String, u32)]

The manifest-declared (address, weight) list — the re-resolution input.

Source

pub fn update_endpoints(&self, resolved: &[(String, u32)]) -> bool

Replace the endpoint set with resolved (address, weight) pairs — the periodic-DNS endpoint-discovery swap. An unchanged pair keeps its instance Arc (health and in-flight state survive, exactly like a reload’s reconcile); a new pair starts pessimistic (ADR 000017 — a fresh address must prove itself before entering rotation); a vanished pair is dropped (in-flight requests finish on their cloned Arc). The LB state is recompiled (a Maglev table indexes the new set). Returns false (and swaps nothing) when the set is unchanged, so an idle refresh tick costs one atomic load and a compare.

Trait Implementations§

Source§

impl Debug for UpstreamGroup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more