Skip to main content

Crate deadpool_citadeldb

Crate deadpool_citadeldb 

Source
Expand description

§Deadpool for CitadelDB

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

This crate implements a deadpool manager for citadeldb and provides async connection pooling via the blocking thread pool.

§Features

FeatureDescriptionExtra dependenciesDefault
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/serde, serde/deriveno

§Example

use deadpool_citadeldb::{Config, Runtime};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cfg = Config::new("", b"secret");
    let pool = cfg.create_pool(Runtime::Tokio1)?;
    let conn = pool.get().await?;
    let result: i64 = conn
        .interact(|inner| {
            inner.execute("CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)")
                .expect("Failed to create table");
            let result = inner.query("SELECT 1")
                .expect("Failed to query");
            let row = result.rows.first().expect("No rows returned");
            let val = row.first().expect("Empty row");
            match val {
                citadel_sql::Value::Integer(i) => *i,
                _ => panic!("Expected integer"),
            }
        })
        .await?;
    assert_eq!(result, 1);
    Ok(())
}

§License

Licensed under either of

at your option.

Re-exports§

pub use config::Config;
pub use config::ConfigError;
pub use citadel;
pub use citadel_sql;

Modules§

config
Configuration support.

Structs§

Manager
Manager for creating and recycling CitadelDB connections.
Metrics
Statistics regarding an object returned by the pool
ObjectId
A unique identifier for an object within a pool.
PoolConfig
Pool configuration.
Status
The current pool status.
SyncGuard
This guard is returned when calling SyncWrapper::lock or SyncWrapper::try_lock. This is basically just a wrapper around a MutexGuard but hides some implementation details.
Timeouts
Timeouts when getting Objects from a Pool.

Enums§

Error
Error type for deadpool-citadeldb.
InteractError
Possible errors returned when SyncWrapper::interact() fails.
Runtime
Enumeration for picking a runtime implementation.
TimeoutType
Possible steps causing the timeout in an error returned by Pool::get() method.

Type Aliases§

BuildError
Type alias for using deadpool::managed::BuildError with [citadeldb].
Connection
Type alias for Object
CreatePoolError
Type alias for using deadpool::managed::CreatePoolError with [citadeldb].
Hook
Type alias for using deadpool::managed::Hook with [citadeldb].
HookError
Type alias for using deadpool::managed::HookError with [citadeldb].
Object
Type alias for using deadpool::managed::Object with [citadeldb].
Pool
Type alias for using deadpool::managed::Pool with [citadeldb].
PoolBuilder
Type alias for using deadpool::managed::PoolBuilder with [citadeldb].
PoolError
Type alias for using deadpool::managed::PoolError with [citadeldb].
WeakPool
Type alias for using deadpool::managed::Pool with [citadeldb].