Skip to main content

Crate pg_pool

Crate pg_pool 

Source
Expand description

Production-grade async connection pool.

Generic over any connection type that implements Poolable. Features: waiter queue with dead-waiter skipping, jittered max-life, health checks on checkout, lifecycle hooks, graceful drain, and metrics.

§Example with pg-wired (requires wire feature)

use pg_pool::{ConnPool, ConnPoolConfig, LifecycleHooks};
use pg_pool::wire::WirePoolable;

let mut config = ConnPoolConfig::default();
config.addr = "127.0.0.1:5432".into();
config.user = "postgres".into();
config.password = "postgres".into();
config.database = "mydb".into();

let _pool = ConnPool::<WirePoolable>::new(config, LifecycleHooks::default()).await?;

Modules§

async_wire
pg-wired AsyncConn integration: implements Poolable for async connections.
wire
pg-wired integration: implements Poolable for pg_wired::WireConn.

Structs§

ConnPool
Production-grade connection pool, generic over connection type C.
ConnPoolConfig
Connection pool configuration.
LifecycleHooks
Lifecycle hook callbacks. All hooks are optional.
PoolGuard
A checked-out connection that returns itself to the pool on drop.
PoolMetrics
Snapshot of pool metrics.

Enums§

PoolError
Errors returned by pool operations.

Traits§

Poolable
Trait for connection types that can be managed by the pool.