Crate deadpool_diesel

Source
Expand description

§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

FeatureDescriptionExtra dependenciesDefault
sqliteEnable sqlite feature in diesel cratediesel/sqliteno
postgresEnable postgres feature in diesel cratediesel/postgresno
mysqlEnable mysql feature in diesel cratediesel/mysqlno
rt_tokio_1Enable support for tokio cratedeadpool/rt_tokio_1yes
rt_async-std_1Enable support for async-std cratedeadpool/rt_async-std_1no
serdeEnable support for serde cratedeadpool/serdeno
tracingEnable 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, tracingno

§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.

Modules§

mysqlmysql
Type aliases for using deadpool-diesel with MySQL.
postgrespostgres
Type aliases for using deadpool-diesel with PostgreSQL.
sqlitesqlite
Type aliases for using deadpool-diesel with SQLite.

Structs§

Manager
Connection Manager for use with diesel.
ManagerConfig
Configuration object for a Manager.
Metrics
Statistics regarding an object returned by the pool
Pool
Generic object and connection pool.
PoolConfig
Pool configuration.
Status
The current pool status.
SyncGuard
This guard is returned when calling SyncWrapper::lock or SyncWrapper::try_lock. This is basicly just a wrapper around a MutexGuard but hides some implementation details.
Timeouts
Timeouts when getting Objects from a Pool.

Enums§

Error
Possible errors returned when managing Connections.
InteractError
Possible errors returned when SyncWrapper::interact() fails.
RecyclingMethod
Possible methods of how a connection is recycled.
Runtime
Enumeration for picking a runtime implementation.

Type Aliases§

Connection
Connection which is returned by the Pool.
PoolError
Type alias for using deadpool::managed::PoolError with diesel.
RecycleCheckCallback
Type of the recycle check callback for the RecyclingMethod::CustomFunction variant