pub struct PoolConfig {
pub max_size: usize,
pub min_idle: usize,
pub create_timeout: Option<Duration>,
pub idle_timeout: Option<Duration>,
pub max_lifetime: Option<Duration>,
}std only.Expand description
Tunable limits and lifecycle policy for a Pool.
Construct one through Pool::builder for the fluent
path, or assemble it directly — every field is public, so a configuration can
equally be deserialized from a settings file. Validation happens when the pool
is built, not when the struct is created; see
Builder::build.
§Examples
use std::time::Duration;
use pool_mod::PoolConfig;
// Start from the defaults and adjust only what matters.
let cfg = PoolConfig {
max_size: 16,
min_idle: 2,
idle_timeout: Some(Duration::from_secs(300)),
..PoolConfig::default()
};
assert_eq!(cfg.max_size, 16);
assert_eq!(cfg.create_timeout, Some(Duration::from_secs(30))); // inherited defaultFields§
§max_size: usizeHard upper bound on the number of resources the pool owns at once — idle plus checked out. Must be at least 1.
min_idle: usizeNumber of resources to create up front when the pool is built, and the
floor the pool keeps ready. Must not exceed max_size.
create_timeout: Option<Duration>How long Pool::get waits for a resource when the
pool is saturated. None waits indefinitely.
idle_timeout: Option<Duration>Discard and replace an idle resource that has gone unused for at least
this long, checked the next time it is borrowed. None disables idle
expiry.
max_lifetime: Option<Duration>Discard and replace a resource older than this, regardless of use,
checked the next time it is borrowed. None disables lifetime expiry.
Trait Implementations§
Source§impl Clone for PoolConfig
impl Clone for PoolConfig
Source§fn clone(&self) -> PoolConfig
fn clone(&self) -> PoolConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PoolConfig
impl Debug for PoolConfig
Source§impl Default for PoolConfig
impl Default for PoolConfig
Source§impl PartialEq for PoolConfig
impl PartialEq for PoolConfig
Source§fn eq(&self, other: &PoolConfig) -> bool
fn eq(&self, other: &PoolConfig) -> bool
self and other values to be equal, and is used by ==.