Skip to main content

PoolConfig

Struct PoolConfig 

Source
pub struct PoolConfig {
Show 16 fields pub min_size: usize, pub max_size: usize, pub acquire_timeout: Option<f64>, pub create_timeout: Option<f64>, pub max_waiters: Option<usize>, pub max_lifetime: Option<f64>, pub lifetime_jitter: f64, pub max_idle_time: Option<f64>, pub max_uses: Option<u64>, pub idle_strategy: IdleStrategy, pub validate_after_idle: Option<f64>, pub maintenance_interval: Option<f64>, pub leak_detection_timeout: Option<f64>, pub validate_idle: bool, pub retry: RetryPolicy, pub breaker: Option<BreakerConfig>,
}
Expand description

An immutable, validated pool configuration. Build one with struct-update syntax from PoolConfig::default, then hand it to a pool — which re-validates it.

use connpool::PoolConfig;
let cfg = PoolConfig { max_size: 20, min_size: 2, ..Default::default() };
assert!(cfg.validate().is_ok());

Fields§

§min_size: usize

Minimum connections kept warm by open() and the maintenance pass.

§max_size: usize

Hard cap on total connections (idle + in use + being created).

§acquire_timeout: Option<f64>

Default wait in acquire().

§create_timeout: Option<f64>

Enforced by the async pool only; blocking factories must enforce their own connect timeout.

§max_waiters: Option<usize>

Backpressure: cap callers blocked in acquire() (None = unlimited; 0 = never wait when full).

§max_lifetime: Option<f64>

Retire connections after this age.

§lifetime_jitter: f64

Shave up to this fraction off each lifetime so a whole pool never expires at once.

§max_idle_time: Option<f64>

Evict idle connections (down to min_size).

§max_uses: Option<u64>

Retire after N checkouts.

§idle_strategy: IdleStrategy

LIFO or FIFO idle reuse.

§validate_after_idle: Option<f64>

Validate on checkout if idle >= this (0 = always, None = never).

§maintenance_interval: Option<f64>

Background sweep period (None = off).

§leak_detection_timeout: Option<f64>

Warn when a borrowed connection is held longer than this (None = off); needs open().

§validate_idle: bool

Validate idle connections during the maintenance sweep and evict dead ones (needs open(); adds I/O).

§retry: RetryPolicy

Retry policy for factory.create().

§breaker: Option<BreakerConfig>

Circuit breaker config (None = off).

Implementations§

Source§

impl PoolConfig

Source

pub fn validate(&self) -> Result<(), PoolError>

Checks the config’s invariants, returning PoolError::Config on the first violation.

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.