pub struct Pool { /* private fields */ }Expand description
A bounded pool of Clients over one endpoint (CLT-080).
At most max_connections connections are live at once; a checkout beyond
that awaits a return. Connections are dialed lazily — construction opens
none — and reused across checkouts so the handshake is paid once per
connection, not once per operation.
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new(
endpoint: impl Into<String>,
config: Config,
client_config: ClientConfig,
max_connections: usize,
) -> Self
pub fn new( endpoint: impl Into<String>, config: Config, client_config: ClientConfig, max_connections: usize, ) -> Self
Build a pool for endpoint. Opens no connections — the first
acquire dials the first one. max_connections is
clamped to at least 1.
Sourcepub async fn acquire(&self) -> Result<PooledConn, ClientError>
pub async fn acquire(&self) -> Result<PooledConn, ClientError>
Check out a connection. Reuses an idle, live connection when one is
available; otherwise dials and handshakes a fresh one (CLT-002). Awaits a
return when max_connections are already checked out. The returned
PooledConn returns the connection to the pool on drop.
Sourcepub fn idle_count(&self) -> usize
pub fn idle_count(&self) -> usize
Idle connections currently parked in the pool. For diagnostics and tests — production code should not branch on it.