Skip to main content

Module connection_pool_manager

Module connection_pool_manager 

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

ConnectionPoolManager
Adaptive connection pool with health checking, multiple acquisition policies, idle/lifetime eviction, event streaming, and dynamic resize.
CpmPoolConfig
Configuration for ConnectionPoolManager.
CpmPoolStats
Point-in-time statistics snapshot for a ConnectionPoolManager.
PooledConnection
A single managed connection inside ConnectionPoolManager.

Enums§

AcquirePolicy
Strategy used to pick an idle connection during ConnectionPoolManager::acquire.
ConnState
Lifecycle state of a single pooled connection.
CpmPoolError
Errors returned by ConnectionPoolManager operations.
PoolEvent
Asynchronous event emitted by pool operations.

Functions§

xorshift64
Simple xorshift64 PRNG used for tie-breaking and test randomness.