#connection-pool

deadpool-aykroyd

Aykroyd micro-ORM for the deadpool connection pool

5 unstable releases

0.3.1 Feb 20, 2024
0.3.0 Jan 31, 2024
0.2.0 Jan 29, 2024
0.1.1 Dec 15, 2023
0.1.0 Dec 15, 2023

#75 in #connection-pool

Download history 44/week @ 2024-07-01 21/week @ 2024-07-08 34/week @ 2024-07-15 90/week @ 2024-07-29 7/week @ 2024-08-05 5/week @ 2024-08-12 9/week @ 2024-09-09 13/week @ 2024-09-16 46/week @ 2024-09-23 38/week @ 2024-09-30 14/week @ 2024-10-07

111 downloads per month

MIT license

180KB
3K SLoC

deadpool-aykroyd

Documentation

aykroyd support library for the deadpool connection pool.

Example

use deadpool_aykroyd::{Manager, ManagerConfig, Pool, RecyclingMethod};
use tokio_postgres::NoTls;

#[derive(aykroyd::QueryOne)]
#[query(row(Row), text = "SELECT 1 + $1")]
struct AddOneTo(i32);

#[derive(aykroyd::FromRow)]
struct Row(i32);

#[tokio::main]
async fn main() {
    let pg_config = "host=localhost user=postgres".parse().unwrap();
    let mgr_config = ManagerConfig {
        recycling_method: RecyclingMethod::Fast
    };
    let mgr = Manager::from_config(pg_config, NoTls, mgr_config);
    let pool = Pool::builder(mgr).max_size(16).build().unwrap();
    for i in 1..10 {
        let mut client = pool.get().await.unwrap();
        let stmt = client.prepare_cached("SELECT 1 + $1").await.unwrap();
        let row = client.query_onw(&AddOneTo(i)).await.unwrap();
        let value = row.0;
        assert_eq!(value, i + 1);
    }
}

Dependencies

~2–11MB
~121K SLoC