Struct HttpPooledConnectorConfig
pub struct HttpPooledConnectorConfig {
pub max_streams_per_connection: Option<NonZero<usize>>,
pub max_connections_total: Option<NonZero<usize>>,
pub max_connections_per_id: Option<NonZero<usize>>,
pub max_idle_per_id: Option<NonZero<usize>>,
pub max_idle_total: Option<NonZero<usize>>,
pub saturation_policy: SaturationPolicy,
pub max_wait_before_dial: Option<Duration>,
pub max_connecting_per_id: Option<NonZero<usize>>,
pub selection: MuxSelection,
pub idle_timeout: Option<Duration>,
pub wait_for_pool_timeout: Option<Duration>,
}dns and http-backend and http and std and tcp only.Expand description
Config used to create a multiplexing http connection pool (MultiplexPool).
Each connection serves as many concurrent requests as it advertises through
its MaxConcurrency extension (1 for
http/1, the peer’s stream limit for http/2 and http/3), unless
max_streams_per_connection is lower. A burst on a multiplexed origin waits
for the connections it needs instead of dialing one per request.
By default nothing is capped: connections close once idle for
idle_timeout, found by later requests to any origin, which close them in
the order they went idle without scanning the pool. A cap below what the
traffic keeps busy costs handshakes: requests queue at a connection limit,
and idle connections closed over an idle limit are dialed again by the
next ones.
Uncapped, a burst on an HTTP/1 origin dials a connection per request, each
holding a local port until it idles out. On a host short of ephemeral ports,
such as a busy proxy on Windows (16,384 by default), cap
max_connections_per_id or max_connections_total: a burst then waits for
connections, as saturation_policy decides, instead of dialing.
A connect failing fails the requests that waited for it, if theirs would fail alike, instead of each dialing again.
Fields§
§max_streams_per_connection: Option<NonZero<usize>>At most this many concurrent requests per connection, below what the
connection allows. None: the peer decides.
max_connections_total: Option<NonZero<usize>>At most this many connections, stored or being established, across all
origins; at the limit saturation_policy decides. None: no limit.
max_connections_per_id: Option<NonZero<usize>>At most this many connections per origin. None: no limit.
max_idle_per_id: Option<NonZero<usize>>Idle connections kept per origin: more close, least recently used
first. None: no limit.
max_idle_total: Option<NonZero<usize>>Idle connections kept across all origins, as max_idle_per_id.
saturation_policy: SaturationPolicyWhat a request that needs a new connection does at a connection limit.
max_wait_before_dial: Option<Duration>How long a request waits for connections being established before it
dials its own, limits permitting. None: it waits for them, until
wait_for_pool_timeout.
max_connecting_per_id: Option<NonZero<usize>>At most this many connections being established per origin at once,
as browsers open few per host: a burst on an HTTP/1 origin then dials
this many at a time. None: a burst dials what it needs.
selection: MuxSelectionHow a connection is chosen among several that can serve a request.
idle_timeout: Option<Duration>Connections idle (no active streams) for longer than this are dropped, as the pool notices: when a request asks it for a connection. One used again since the pool last looked at it may go up to this much later. 90 s by default, as established clients do: peers tend to close idle connections sooner than that.
wait_for_pool_timeout: Option<Duration>How long a request waits for the pool to hand out a connection, and again for a new connection to admit it; a request waiting for another’s new connection dials its own by then. The handshake is not bounded by it. A request’s own timeout applies by dropping the request, which leaves nothing behind in the pool.
Implementations§
§impl HttpPooledConnectorConfig
impl HttpPooledConnectorConfig
pub fn build_pool<C, ID>(&self) -> MultiplexPool<C, ID>
pub fn build_pool<C, ID>(&self) -> MultiplexPool<C, ID>
The pool this config describes, for a PooledConnector of one’s own:
wait_for_pool_timeout is the connector’s, not the pool’s. With ID
opaque, its streams hint goes only by the version a request targets or
speaks; Self::build_connector also expects a secure HTTP origin to
multiplex, as its TLS offers h2.
pub fn build_connector<S>(
self,
inner: S,
) -> BindBodyToConnector<PooledConnector<S, MultiplexPool<<S as ConnectorService<ConnectRequest>>::Connection, HttpConnId>, HttpConnIdentifier>>where
S: ConnectorService<ConnectRequest>,
pub fn build_connector<S>(
self,
inner: S,
) -> BindBodyToConnector<PooledConnector<S, MultiplexPool<<S as ConnectorService<ConnectRequest>>::Connection, HttpConnId>, HttpConnIdentifier>>where
S: ConnectorService<ConnectRequest>,
Build a pooled HTTP connector around inner.
The connector only adds body binding and pool lookup. HTTP request
adaptation and proxy-route selection remain independently composable
services and can be layered around the returned connector when needed.
The pool belongs to one fixed connector policy, including TLS defaults
and native hooks. Retire it before changing that policy or mutable hook
behavior. Transport connectors publish their request compatibility rules
as connection metadata. Custom identifiers may further partition routes
through Self::build_connector_with_identifier.
A pool injected through request extensions must obey the same fixed-policy contract. Share it only between compatible connectors, or supply a custom connection ID that separates their policies.
The returned connector wraps each pooled connection in
BindBodyToConn, so the pool only frees/reuses a
connection once its response body has been consumed, not at response
headers.
Warning: the connection returned by this pool should only be used for a single request. Every request should go through the connector stack again, and will receive a new or reused connection (maybe multiplexed) of its own.
pub fn build_connector_with_identifier<S, R>(
self,
inner: S,
identifier: R,
) -> BindBodyToConnector<PooledConnector<S, MultiplexPool<<S as ConnectorService<ConnectRequest>>::Connection, HttpConnId>, R>>
pub fn build_connector_with_identifier<S, R>( self, inner: S, identifier: R, ) -> BindBodyToConnector<PooledConnector<S, MultiplexPool<<S as ConnectorService<ConnectRequest>>::Connection, HttpConnId>, R>>
Build a pool with a custom identifier for the fixed policy of inner.
Trait Implementations§
§impl Clone for HttpPooledConnectorConfig
impl Clone for HttpPooledConnectorConfig
§fn clone(&self) -> HttpPooledConnectorConfig
fn clone(&self) -> HttpPooledConnectorConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for HttpPooledConnectorConfig
impl Debug for HttpPooledConnectorConfig
§impl Default for HttpPooledConnectorConfig
impl Default for HttpPooledConnectorConfig
§fn default() -> HttpPooledConnectorConfig
fn default() -> HttpPooledConnectorConfig
Auto Trait Implementations§
impl Freeze for HttpPooledConnectorConfig
impl RefUnwindSafe for HttpPooledConnectorConfig
impl Send for HttpPooledConnectorConfig
impl Sync for HttpPooledConnectorConfig
impl Unpin for HttpPooledConnectorConfig
impl UnsafeUnpin for HttpPooledConnectorConfig
impl UnwindSafe for HttpPooledConnectorConfig
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more