pub struct PoolConfig {
pub min_size: usize,
pub max_size: usize,
pub acquire_timeout: Duration,
pub idle_timeout: Duration,
pub max_lifetime: Duration,
pub health_check_on_acquire: bool,
pub health_check_interval: Option<Duration>,
pub evict_unhealthy: bool,
pub warmup_connections: usize,
pub warmup_timeout: Duration,
pub warmup_failure_strategy: WarmupStrategy,
}Expand description
Configuration for a generic resource pool.
Fields§
§min_size: usizeMinimum resources to keep in pool.
max_size: usizeMaximum resources in pool.
acquire_timeout: DurationTimeout for acquire operations.
idle_timeout: DurationMaximum time a resource can be idle before eviction.
max_lifetime: DurationMaximum lifetime of a resource.
health_check_on_acquire: boolPerform health check before returning idle resources.
health_check_interval: Option<Duration>Periodic health check interval for idle resources.
If None, periodic health checks are disabled.
evict_unhealthy: boolRemove unhealthy resources immediately when detected.
warmup_connections: usizePre-create this many connections on pool init.
warmup_timeout: DurationTimeout for warmup phase.
warmup_failure_strategy: WarmupStrategyStrategy when warmup partially fails.
Implementations§
Source§impl PoolConfig
impl PoolConfig
Sourcepub fn with_max_size(max_size: usize) -> Self
pub fn with_max_size(max_size: usize) -> Self
Creates a new pool configuration with the given max size.
Sourcepub fn acquire_timeout(self, timeout: Duration) -> Self
pub fn acquire_timeout(self, timeout: Duration) -> Self
Sets the acquire timeout.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
pub fn idle_timeout(self, timeout: Duration) -> Self
Sets the idle timeout.
Sourcepub fn max_lifetime(self, lifetime: Duration) -> Self
pub fn max_lifetime(self, lifetime: Duration) -> Self
Sets the max lifetime.
Sourcepub fn health_check_on_acquire(self, enabled: bool) -> Self
pub fn health_check_on_acquire(self, enabled: bool) -> Self
Enables health checking before returning idle resources.
Sourcepub fn health_check_interval(self, interval: Option<Duration>) -> Self
pub fn health_check_interval(self, interval: Option<Duration>) -> Self
Sets the periodic health check interval for idle resources.
Sourcepub fn evict_unhealthy(self, evict: bool) -> Self
pub fn evict_unhealthy(self, evict: bool) -> Self
Sets whether to immediately evict unhealthy resources.
Sourcepub fn warmup_connections(self, count: usize) -> Self
pub fn warmup_connections(self, count: usize) -> Self
Sets the number of connections to pre-create during warmup.
Sourcepub fn warmup_timeout(self, timeout: Duration) -> Self
pub fn warmup_timeout(self, timeout: Duration) -> Self
Sets the timeout for the warmup phase.
Sourcepub fn warmup_failure_strategy(self, strategy: WarmupStrategy) -> Self
pub fn warmup_failure_strategy(self, strategy: WarmupStrategy) -> Self
Sets the strategy for handling partial warmup failures.
Trait Implementations§
Source§impl Clone for PoolConfig
impl Clone for PoolConfig
Source§fn clone(&self) -> PoolConfig
fn clone(&self) -> PoolConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more