Skip to main content

pg_pool/
lib.rs

1//! Production-grade async connection pool.
2//!
3//! Generic over any connection type that implements [`Poolable`].
4//! Features: waiter queue with dead-waiter skipping, jittered max-life,
5//! health checks on checkout, lifecycle hooks, graceful drain, and metrics.
6//!
7//! # Example with pg-wired (requires `wire` feature)
8//!
9//! ```no_run
10//! # #[cfg(feature = "wire")]
11//! # async fn _doctest() -> Result<(), Box<dyn std::error::Error>> {
12//! use pg_pool::{ConnPool, ConnPoolConfig, LifecycleHooks};
13//! use pg_pool::wire::WirePoolable;
14//!
15//! let mut config = ConnPoolConfig::default();
16//! config.addr = "127.0.0.1:5432".into();
17//! config.user = "postgres".into();
18//! config.password = "postgres".into();
19//! config.database = "mydb".into();
20//!
21//! let _pool = ConnPool::<WirePoolable>::new(config, LifecycleHooks::default()).await?;
22//! # Ok(()) }
23//! ```
24
25#![deny(missing_docs)]
26
27#[cfg(feature = "wire")]
28pub mod async_wire;
29mod pool;
30#[cfg(feature = "wire")]
31pub mod wire;
32
33pub use pool::{
34    ConnPool, ConnPoolConfig, LifecycleHooks, PoolError, PoolGuard, PoolMetrics, Poolable,
35};