Expand description
§Deadpool for Diesel

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
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Modules§
- mysql
mysql
- Type aliases for using
deadpool-diesel
with MySQL. - postgres
postgres
- Type aliases for using
deadpool-diesel
with PostgreSQL. - sqlite
sqlite
- Type aliases for using
deadpool-diesel
with SQLite.
Structs§
- Manager
Connection
Manager
for use withdiesel
.- Manager
Config - Configuration object for a Manager.
- Metrics
- Statistics regarding an object returned by the pool
- Pool
- Generic object and connection pool.
- Pool
Config Pool
configuration.- Status
- The current pool status.
- Sync
Guard - This guard is returned when calling
SyncWrapper::lock
orSyncWrapper::try_lock
. This is basicly just a wrapper around aMutexGuard
but hides some implementation details. - Timeouts
- Timeouts when getting
Object
s from aPool
.
Enums§
- Error
- Possible errors returned when managing
Connection
s. - Interact
Error - Possible errors returned when
SyncWrapper::interact()
fails. - Recycling
Method - 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
. - Pool
Error - Type alias for using
deadpool::managed::PoolError
withdiesel
. - Recycle
Check Callback - Type of the recycle check callback for the
RecyclingMethod::CustomFunction
variant