UpstreamRegistry

Struct UpstreamRegistry 

Source
pub struct UpstreamRegistry { /* private fields */ }
Expand description

Registry of per-upstream pooled clients, built from one published snapshot. Rebuild (and drop the old registry) on snapshot swap; in-flight requests keep their old pools until their handles are dropped.

Implementations§

Source§

impl UpstreamRegistry

Source

pub fn from_snapshot(snapshot: &Snapshot) -> Self

Build from a snapshot, verifying upstream TLS certificates against the Mozilla webpki root set — except upstreams that configure trusted_ca_file, which verify against their own bundle (#121).

Source

pub fn from_snapshot_with_previous( snapshot: &Snapshot, previous: &UpstreamRegistry, ) -> Self

Build from a snapshot, carrying over per-upstream load-balancer state from previous (in-flight counters, WRR phase, slow-start clocks for unchanged endpoint addresses). This is the reload path: weight and endpoint changes take effect without a restart, and in-flight requests holding old handles are unaffected.

Source

pub fn from_snapshot_with_events( snapshot: &Snapshot, events: Option<&Emitter>, ) -> Self

from_snapshot with the dataplane’s event emitter attached (DW-044): breaker transitions and endpoint ejection/recovery in this registry’s state machines emit onto the bus. Distinct constructors rather than a changed signature so the many event-agnostic call sites (tests, tooling) stay untouched.

Source

pub fn from_snapshot_with_previous_and_events( snapshot: &Snapshot, previous: &UpstreamRegistry, events: Option<&Emitter>, ) -> Self

from_snapshot_with_previous with the dataplane’s event emitter attached (DW-044); the dataplane’s reload path.

Source

pub fn with_root_certificates( snapshot: &Snapshot, extra_roots: &[CertificateDer<'_>], ) -> Result<Self, UpstreamError>

Build from a snapshot with EXTRA trusted root certificates (e.g. a private CA signing upstream certificates), added on top of the webpki roots. Fails if any extra root is malformed, so operators see the bad certificate at registry build time rather than as a mysterious handshake failure later.

Source

pub fn with_root_certificates_and_previous( snapshot: &Snapshot, extra_roots: &[CertificateDer<'_>], previous: Option<&UpstreamRegistry>, ) -> Result<Self, UpstreamError>

with_root_certificates with optional balancer-state carry-over from a previous registry build (see UpstreamRegistry::from_snapshot_with_previous).

Per-upstream trusted_ca_file (#121): when set, that upstream’s connector trusts the file’s bundle INSTEAD of the webpki+extras store — a private-CA upstream must not implicitly keep public-root trust. Config-driven bundles that fail to load at build time do NOT fail the build (the config was file-validated at publish, so this is a torn state — the bundle was replaced/unlinked underneath the gateway); the upstream FAILS CLOSED with an empty root store and a loud error log, so no traffic is ever sent under trust the operator did not configure. Programmatic extra_roots keep the immediate-Err contract above.

Source

pub fn with_root_certificates_previous_and_events( snapshot: &Snapshot, extra_roots: &[CertificateDer<'_>], previous: Option<&UpstreamRegistry>, events: Option<&Emitter>, ) -> Result<Self, UpstreamError>

with_root_certificates_and_previous with the dataplane’s event emitter (DW-044); the single build path behind every constructor.

Source

pub fn split_for(&self, service: &str) -> Option<Arc<ServiceSplit>>

The compiled split for a service (DW-040), when it has one.

Source

pub fn get(&self, name: &str) -> Option<Arc<UpstreamHandle>>

Handle for the named upstream, or None if the snapshot has no such upstream.

Source

pub fn names(&self) -> Vec<&str>

Names of all upstreams in this registry.

Source

pub fn set_locality_context(&self, ctx: LocalityContext)

DW-094 (Ent): set the edge’s locality context on every upstream’s load balancer in this registry. Called by the dataplane at startup and on refresh to propagate the edge’s region/zone.

Source

pub fn with_rebuilt_split_from_pairs( &self, service: &str, pairs: &[(String, u64)], ) -> Option<UpstreamRegistry>

DW-091: rebuild the split for service from explicit (upstream_name, weight) pairs. Returns a new registry with the replacement split; the handles are shared (Arc bump). The total weight MUST stay constant (the caller enforces this); changing the total would reshuffle every session’s branch (the DW-040 invariant).

Source

pub fn pre_warm(&self)

SCALE-10 (#189): pre-warm connection pools for upstreams that configure pool.pre_warm. For each upstream with a non-zero pre_warm value, spawns a background task that sends lightweight HEAD requests to each endpoint to establish pre_warm connections in the pool. This removes cold-start latency spikes after reloads and upgrade hand-offs. Failures are logged and silently ignored (pre-warming is best-effort; a failed pre-warm does not affect the upstream’s availability).

Trait Implementations§

Source§

impl Default for UpstreamRegistry

Source§

fn default() -> UpstreamRegistry

Returns the “default value” for a type. 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
§

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

§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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
§

impl<T, X> CoerceTo<T> for X
where 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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,