Expand description
Connection Pool Manager
Production-quality connection pool with health checking, adaptive sizing, multiple acquisition policies, idle/lifetime eviction, and event streaming.
§Overview
ConnectionPoolManager maintains a collection of PooledConnection objects
keyed by auto-increment IDs. Connections move through the ConnState lifecycle
(Idle → InUse → Idle | Draining | Closed) and are evicted by background
maintenance when they exceed configured timeouts.
§Example
use ipfrs_network::connection_pool_manager::{
ConnectionPoolManager, CpmPoolConfig, AcquirePolicy,
};
let config = CpmPoolConfig {
min_connections: 1,
max_connections: 8,
idle_timeout_us: 30_000_000,
max_lifetime_us: 3_600_000_000,
health_check_interval_us: 10_000_000,
acquire_timeout_us: 5_000_000,
policy: AcquirePolicy::HealthBest,
};
let mut pool = ConnectionPoolManager::new(config);
let id = pool.add_connection("127.0.0.1:9000".to_string(), vec![]).unwrap();
let acquired = pool.acquire(1_000).unwrap();
pool.release(acquired, 2_000, false).unwrap();Structs§
- Connection
Pool Manager - Adaptive connection pool with health checking, multiple acquisition policies, idle/lifetime eviction, event streaming, and dynamic resize.
- CpmPool
Config - Configuration for
ConnectionPoolManager. - CpmPool
Stats - Point-in-time statistics snapshot for a
ConnectionPoolManager. - Pooled
Connection - A single managed connection inside
ConnectionPoolManager.
Enums§
- Acquire
Policy - Strategy used to pick an idle connection during
ConnectionPoolManager::acquire. - Conn
State - Lifecycle state of a single pooled connection.
- CpmPool
Error - Errors returned by
ConnectionPoolManageroperations. - Pool
Event - Asynchronous event emitted by pool operations.
Functions§
- xorshift64
- Simple xorshift64 PRNG used for tie-breaking and test randomness.