Deadpool is a dead simple async pool for connections and objects of any type.
This crate implements a deadpool
manager for r2d2
managers.
| Feature | Description | Extra dependencies | Default |
| ------- | ----------- | ------------------ | ------- |
| rt_tokio_1
| Enable support for tokio crate | deadpool/rt_tokio_1
| yes |
| rt_async-std_1
| Enable support for async-std crate | deadpool/rt_async-std_1
| no |
| serde
| Enable support for serde crate | deadpool/serde
| no |
```rust use std::env;
use deadpoolr2d2::Runtime; use r2d2postgres::postgres::Error as PgError;
type PgManager = deadpoolr2d2::Manager<
r2d2postgres::PostgresConnectionManager
; type PgPool = deadpool_r2d2::Pool
;
fn createpool(maxsize: usize) -> PgPool { let mut pgconfig = r2d2postgres::postgres::Config::new(); pgconfig.hostpath("/run/postgresql"); pgconfig.user(&env::var("USER").unwrap()); pgconfig.dbname("deadpool"); let r2d2manager = r2d2postgres::PostgresConnectionManager::new(pgconfig, r2d2postgres::postgres::NoTls); let manager = PgManager::new(r2d2manager, Runtime::Tokio1); let pool = PgPool::builder(manager) .maxsize(max_size) .build() .unwrap(); pool }
async fn main() -> Result<(), Box
Licensed under either of
at your option.