Skip to main content

Module pool

Module pool 

Source
Expand description

Outbound connection pool with backoff and auto-eject.

Two pool flavors share the same policy in this codebase: the per-datastore pool that hands a Redis or memcache backend connection to a CLIENT FSM, and the per-peer pool that hands a peer connection to the cluster routing layer. Both share:

  • a cap on the active connection count (max_connections),
  • round-robin across slots keyed on a caller-supplied tag,
  • exponential connect-failure backoff (doubling the timeout each time, capped at max_timeout),
  • auto-eject of the host after failure_limit consecutive failures, with retry after retry_after.

ConnPool reproduces the policy in safe Rust. Connections are manufactured by a caller-supplied ConnFactory (so tests can inject failure-injecting transports) and handed back to the pool through ConnHandle::release.

§Examples

use dynomite::net::pool::{ConnPool, ConnPoolConfig};
use dynomite::io::reactor::TcpTransport;

let pool: ConnPool<TcpTransport> = ConnPool::new(ConnPoolConfig {
    max_connections: 4,
    server_failure_limit: 3,
    server_retry_timeout_ms: 1_000,
    auto_eject: true,
});
assert_eq!(pool.config().max_connections, 4);

Structs§

ConnHandle
Handle returned by ConnPool::get.
ConnPool
Outbound connection pool.
ConnPoolConfig
Tunable knobs taken straight from the YAML pool block.

Traits§

ConnFactory
Factory that produces a fresh connection on demand.

Type Aliases§

ConnFuture
Boxed future returned by a ConnFactory.