Skip to main content

HttpPooledConnectorConfig

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>,
}
Available on crate features 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: SaturationPolicy

What 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: MuxSelection

How 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

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

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

Build a pool with a custom identifier for the fixed policy of inner.

Trait Implementations§

§

impl Clone for HttpPooledConnectorConfig

§

fn clone(&self) -> HttpPooledConnectorConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for HttpPooledConnectorConfig

§

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

Formats the value using the given formatter. Read more
§

impl Default for HttpPooledConnectorConfig

§

fn default() -> HttpPooledConnectorConfig

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<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,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

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

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

fn with_current_context(self) -> WithContext<Self> ⓘ

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

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> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a rama_grpc::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
§

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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

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

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

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

§

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

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
§

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