#connection-pool

bb8-aykroyd

Aykroyd micro-ORM for the bb8 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

#61 in #connection-pool

Download history 23/week @ 2024-07-29 21/week @ 2024-08-05 4/week @ 2024-08-12 11/week @ 2024-09-09 21/week @ 2024-09-16 58/week @ 2024-09-23 70/week @ 2024-09-30 19/week @ 2024-10-07 4/week @ 2024-10-14 27/week @ 2024-10-21 8/week @ 2024-10-28 16/week @ 2024-11-04

56 downloads per month

MIT license

180KB
3K SLoC

bb8-aykroyd

Documentation

aykroyd support library for the bb8 connection pool.

Example

use bb8_aykroyd::AykroydConnectionManager;
use tokio_postgres::tls::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 manager = AykroydConnectionManager::new(
        "host=localhost user=postgres".parse().unwrap(),
        NoTls,
    );
    let pool = bb8::Pool::builder()
        .max_size(15)
        .build(manager)
        .await
        .unwrap();

    for i in 0..20 {
        let pool = pool.clone();
        tokio::spawn(async move {
            let client = pool.get().await.unwrap();

            let row = client.query_one(&AddOneTo(i)).await.unwrap();
            let value = row.0;
            assert_eq!(value, i + 1);
        });
    }
}

Dependencies

~3–12MB
~138K SLoC