Skip to main content

PoolConfig

Struct PoolConfig 

Source
pub struct PoolConfig {
    pub max_idle_per_origin: usize,
    pub idle_timeout: Duration,
    pub max_connection_lifetime: Option<Duration>,
    pub max_conns_per_origin: usize,
    pub h2_target_streams_per_conn: usize,
    pub h2_min_conns_per_origin: usize,
    pub h2_max_conns_per_origin: usize,
    pub h2_scale: ScaleThresholds,
    pub checkout_timeout: Option<Duration>,
    pub h2_zero_capacity_drain: Duration,
}
Expand description

Pool limits and timeouts.

Fields§

§max_idle_per_origin: usize

Idle HTTP/1 connections kept per origin (default 256, the same as max_conns_per_origin, so a burst does not close connections it will want again; idle_timeout closes the unused ones). Each idle connection holds a file descriptor: lower this for clients that talk to many origins.

§idle_timeout: Duration

Idle HTTP/1 connections older than this are discarded at checkout, and HTTP/2 connections without streams for this long are closed (default 90 s).

§max_connection_lifetime: Option<Duration>

Connections are retired once they are this old, so traffic follows DNS and load-balancer changes (default None: no limit). HTTP/1 connections are closed when they are next returned or checked out; an HTTP/2 connection stops taking new streams after its replacement is up and closes once its in-flight requests finish.

§max_conns_per_origin: usize

HTTP/1: maximum connections (in use + idle + dialing) per origin (default 256).

§h2_target_streams_per_conn: usize

Streams per HTTP/2 connection (default 128, or less when the server’s MAX_CONCURRENT_STREAMS is lower). Requests beyond it go to another connection, which the pool dials if needed.

§h2_min_conns_per_origin: usize

HTTP/2 connections kept per origin: dialed eagerly once the origin is known to speak h2 and never scaled below (default 1). Leave it alone: the pool adds connections under load by itself.

§h2_max_conns_per_origin: usize

HTTP/2 autoscaling ceiling per origin (default: std::thread::available_parallelism(); one connection is one actor task, so more connections than cores cannot add parallelism). Autoscaling also stays within the tokio runtime’s worker count (unless h2_min_conns_per_origin is higher). Set equal to h2_min_conns_per_origin to pin the connection count. Replacing a connection past max_connection_lifetime may exceed it by one for a moment. See scale for the policy.

§h2_scale: ScaleThresholds

HTTP/2 scale-up thresholds (defaults: the constants in scale).

§checkout_timeout: Option<Duration>

Maximum time a request waits for a connection or stream slot (default 30 s; None waits forever). Failure is PoolTimeout with Recovery::Unprocessed.

§h2_zero_capacity_drain: Duration

An HTTP/2 connection whose peer advertises SETTINGS_MAX_CONCURRENT_STREAMS = 0 is retired after this long (default 10 s). Such a connection never counts as capacity and never triggers scale-up.

Trait Implementations§

Source§

impl Clone for PoolConfig

Source§

fn clone(&self) -> Self

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

impl Debug for PoolConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PoolConfig

Source§

fn default() -> Self

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

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