pub struct OutboundClient {
verified: Client<HttpsConnector<HttpConnector>, Full<Bytes>>,
insecure: OnceLock<Client<HttpsConnector<HttpConnector>, Full<Bytes>>>,
custom: RwLock<HashMap<u64, Client<HttpsConnector<HttpConnector>, Full<Bytes>>>>,
}Expand description
Process-wide pooled HTTP client.
Fields§
§verified: Client<HttpsConnector<HttpConnector>, Full<Bytes>>§insecure: OnceLock<Client<HttpsConnector<HttpConnector>, Full<Bytes>>>Built on first ssl_verify: false request; never constructed on the
common path.
custom: RwLock<HashMap<u64, Client<HttpsConnector<HttpConnector>, Full<Bytes>>>>Clients for per-upstream TLS identities (mTLS / private CA), keyed by the identity’s content hash. Never evicted — bounded by the number of distinct identities ever configured.
Implementations§
Source§impl OutboundClient
impl OutboundClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Builds the shared client. TLS uses the platform’s native root store.
Advertises both HTTP/1.1 and HTTP/2 via ALPN, so TLS upstreams that
support h2 (e.g. gRPC backends) are served over HTTP/2 while plain-http
upstreams stay HTTP/1.1.
Sourcepub async fn request(
&self,
req: OutboundRequest,
) -> Result<OutboundResponse, OutboundError>
pub async fn request( &self, req: OutboundRequest, ) -> Result<OutboundResponse, OutboundError>
Performs the request, honoring timeout and ssl_verify.
Sourcepub async fn request_streaming(
&self,
req: OutboundRequest,
) -> Result<OutboundStreamingResponse, OutboundError>
pub async fn request_streaming( &self, req: OutboundRequest, ) -> Result<OutboundStreamingResponse, OutboundError>
Like request but returns as soon as the response
headers arrive, leaving the body to stream. req.timeout bounds
connect + request + headers; the caller owns any idle bound on the body.
Sourceasync fn dispatch(
&self,
req: &OutboundRequest,
) -> Result<Response<Incoming>, OutboundError>
async fn dispatch( &self, req: &OutboundRequest, ) -> Result<Response<Incoming>, OutboundError>
Builds and dispatches the outbound request, yielding the response with
its body still unread. Shared by request and request_streaming so
the two can never drift in connector, TLS or header handling.
Sourcefn identity_client(
&self,
identity: &Arc<UpstreamTls>,
) -> Result<Client<HttpsConnector<HttpConnector>, Full<Bytes>>, OutboundError>
fn identity_client( &self, identity: &Arc<UpstreamTls>, ) -> Result<Client<HttpsConnector<HttpConnector>, Full<Bytes>>, OutboundError>
Returns the pooled client for identity, building it on first use.
ALPN advertises h1+h2 like the default client (hyper-rustls sets the
protocols on the config in enable_http1/enable_http2).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OutboundClient
impl !RefUnwindSafe for OutboundClient
impl !UnwindSafe for OutboundClient
impl Send for OutboundClient
impl Sync for OutboundClient
impl Unpin for OutboundClient
impl UnsafeUnpin for OutboundClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§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