UpstreamHandle

Struct UpstreamHandle 

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

A send-capable handle to one configured upstream: a dedicated pooled hyper client plus observability. Cheap to share via Arc from the UpstreamRegistry.

Implementations§

Source§

impl UpstreamHandle

Source

pub fn name(&self) -> &str

Upstream name this handle serves.

Source

pub fn cap(&self) -> u32

Effective connection cap (explicit or default, minimum 1).

Source

pub fn connect_timeout(&self) -> Duration

Effective connect timeout (explicit or default).

Source

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

Effective happy-eyeballs delay (DW-030); None = racing disabled.

Source

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

Per-attempt read timeout (timeouts.read_ms), if configured.

Source

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

Response-body inactivity timeout (timeouts.write_ms), if configured.

Source

pub fn retry_params(&self) -> &RetryParams

Resolved retry parameters (DW-014). attempts == 0 = retries off.

Source

pub fn hedge_params(&self) -> &HedgeParams

Resolved hedge parameters (DW-063).

Source

pub fn retry_budget(&self) -> &Arc<RetryBudget>

This upstream’s rolling-window retry budget (DW-014).

Source

pub fn max_pending(&self) -> u32

Effective pending cap (DW-015); 0 = unbounded queueing.

Source

pub fn breaker(&self) -> &Arc<Breaker>

This upstream’s circuit breaker state (DW-015). Always present; consult UpstreamHandle::breaker_params first — a None there means the breaker is disabled and the state object is dormant.

Source

pub fn breaker_params(&self) -> Option<&BreakerParams>

Resolved breaker parameters (DW-015); None = breaker disabled.

Source

pub fn connections_opened(&self) -> u64

Total connections established since the handle was built.

Source

pub fn requests_sent(&self) -> u64

Total requests sent through the pool.

Source

pub fn scheme(&self) -> &str

Effective scheme this upstream dials (“http” or “https”).

Source

pub fn lb(&self) -> &Arc<UpstreamLb>

This upstream’s load balancer (endpoint set, algorithm, in-flight counters). Exposed for the TLS-passthrough path (which picks an endpoint the same way) and for tests.

Source

pub fn hash_on(&self) -> Option<&HashOn>

DP-07 (#236): the hash-key source for this upstream’s consistent-hash load balancer (ip_hash or maglev). None means the client IP is used (the default).

Source

pub fn set_locality_context(&self, ctx: LocalityContext)

DW-094 (Ent): set the edge’s locality context on this upstream’s load balancer. Called by the dataplane at startup to propagate the edge’s region/zone (from env vars or edge labels) to every upstream’s balancer.

Source

pub fn tls_roots(&self) -> Option<&RootCertStore>

The trust roots this upstream’s TLS connections verify against (#121): None for plaintext http1 upstreams, the configured trusted_ca_file bundle when set, else the webpki public set. Active https health probes clone this so a probe and a proxied request can never disagree about who to trust.

Source

pub fn h3_handle(&self) -> Option<&Arc<H3UpstreamHandle>>

DW-108: the H3/QUIC upstream transport, when this upstream is protocol: h3 AND the h3 cargo feature is enabled. The QUIC active health probe reuses its TLS client config (trust roots + h3 ALPN) so a probe and a proxied request trust the same roots. None for non-H3 upstreams or when the feature is off.

Source

pub fn protocol(&self) -> UpstreamProtocol

The configured upstream protocol (DW-108). H3 selects the QUIC transport; the other variants use the TCP/TLS pooled client.

Source

pub async fn send<B>( &self, req: Request<B>, ) -> Result<Response<UpstreamBody>, UpstreamError>
where B: Body<Data = Bytes> + Send + 'static, B::Error: Into<Box<dyn Error + Send + Sync>>,

Send a request through this upstream’s pool without a hash key (algorithms other than ip_hash ignore the key anyway).

Source

pub async fn send_with_hash_key<B>( &self, req: Request<B>, hash_key: Option<&str>, ) -> Result<Response<UpstreamBody>, UpstreamError>
where B: Body<Data = Bytes> + Send + 'static, B::Error: Into<Box<dyn Error + Send + Sync>>,

Send a request through this upstream’s pool, dispatching via the upstream’s load balancer (DW-011). hash_key is the client IP as a string (used by ip_hash; ignored by the other algorithms). The picked endpoint’s address:port becomes both the dialed URI’s authority and the outbound Host header (replacing whatever the caller set); the path and query are preserved verbatim. The picked endpoint’s in-flight counter is held for the request/response-header exchange (documented approximation: released when headers resolve, not when the streaming body completes). The response body streams (wrapped in UpstreamBody for the DW-014 write-timeout / mid-body health reporting knobs; the wrapper is a frame-for-frame passthrough when both are unset), so proxying (DW-009) can forward it without buffering.

Source

pub async fn send_with_hash_key_observed<B>( &self, req: Request<B>, hash_key: Option<&str>, picked: &mut Option<String>, ) -> Result<Response<UpstreamBody>, UpstreamError>
where B: Body<Data = Bytes> + Send + 'static, B::Error: Into<Box<dyn Error + Send + Sync>>,

UpstreamHandle::send_with_hash_key with observability (DW-021): the load-balancer pick runs under an upstream_pick span (child of the caller’s upstream_attempt span) and the picked endpoint’s address:port is written to picked when a dispatch resolved (left None on the NoEndpoints guard), so the proxy can attribute the attempt in its access log and the upstream_attempts_total metric.

Trait Implementations§

Source§

impl Debug for UpstreamHandle

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
§

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,