#connection-pool

deadpool-diesel

Dead simple async pool for diesel

11 unstable releases (5 breaking)

0.6.1 May 4, 2024
0.6.0 Mar 31, 2024
0.5.0 Sep 26, 2023
0.4.1 Dec 9, 2022
0.1.2 Jul 16, 2021

#35 in #connection-pool

Download history 3191/week @ 2024-07-19 3212/week @ 2024-07-26 3365/week @ 2024-08-02 2950/week @ 2024-08-09 2659/week @ 2024-08-16 2678/week @ 2024-08-23 2723/week @ 2024-08-30 2797/week @ 2024-09-06 2917/week @ 2024-09-13 2602/week @ 2024-09-20 2444/week @ 2024-09-27 2413/week @ 2024-10-04 2110/week @ 2024-10-11 2429/week @ 2024-10-18 2227/week @ 2024-10-25 2655/week @ 2024-11-01

9,749 downloads per month

MIT/Apache

99KB
1.5K SLoC

Deadpool for Diesel Latest Version Unsafe forbidden Rust 1.75+

Deadpool is a dead simple async pool for connections and objects of any type.

This crate implements a deadpool manager for diesel connections.

Features

Feature Description Extra dependencies Default
sqlite Enable sqlite feature in diesel crate diesel/sqlite no
postgres Enable postgres feature in diesel crate diesel/postgres no
mysql Enable mysql feature in diesel crate diesel/mysql no
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
tracing Enable support for tracing by propagating Spans in the interact() calls. Enable this if you use the tracing crate and you want to get useful traces from within interact() calls. deadpool-sync/tracing, tracing no

Example

use deadpool_diesel::sqlite::{Runtime, Manager, Pool};
use diesel::{prelude::*, select, sql_types::Text};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let manager = Manager::new(":memory:", Runtime::Tokio1);
    let pool = Pool::builder(manager)
        .max_size(8)
        .build()
        .unwrap();
    let conn = pool.get().await?;
    let result = conn.interact(|conn| {
        let query = select("Hello world!".into_sql::<Text>());
        query.get_result::<String>(conn)
    }).await??;
    assert!(result == "Hello world!");
    Ok(())
}

License

Licensed under either of

at your option.

Dependencies

~5–19MB
~277K SLoC