pg-pool
Generic async connection pool for any connection type that implements
the Poolable trait. Ships with a first-class
pg-wired integration behind the default wire
feature, but the core pool is protocol-agnostic.
What's in the box
- Checkout / checkin with configurable min and max connections.
- Six lifecycle hooks covering create, acquire, checkout, checkin,
release, and destroy. Connection-aware where applicable, so you can
e.g.
RESET ALLat checkin orSET application_nameat checkout. - Idle timeout with a background reaper.
- Optional health-probe task that pings idle connections and evicts ones the server has torn down.
Metricssnapshot (active, idle, waiters, creates, destroys, timeouts) for Prometheus scraping or ad-hoc logging.- Graceful drain: stop accepting new waiters and return once all in-flight checkouts return.
Minimal example
use ;
use WirePoolable;
async
Features
| feature | default | enables |
|---|---|---|
wire |
yes | Poolable impl for pg_wired::WireConn plus helper constructors. |
Architecture
See ARCHITECTURE.md for the internals: the Poolable trait, data layout (atomics + mutexed deques), the acquire and release paths, the six lifecycle hooks, the drain protocol, and hook safety rules.
License
Dual licensed under Apache 2.0 or MIT. See the workspace root for the broader project.