Expand description
bolt_client
support for the deadpool
connection pool.
§Example
use std::env;
use deadpool_bolt::{
bolt_client::Metadata,
bolt_proto::{version::*, Value},
Manager,
Pool,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure a connection manager. We'll request Bolt v4.4 or v4.3.
let manager = Manager::new(
env::var("BOLT_TEST_ADDR")?,
env::var("BOLT_TEST_DOMAIN").ok(),
[V4_4, V4_3, 0, 0],
Metadata::from_iter(vec![
("user_agent", "bolt-client/X.Y.Z"),
("scheme", "basic"),
("principal", &env::var("BOLT_TEST_USERNAME")?),
("credentials", &env::var("BOLT_TEST_PASSWORD")?),
]),
).await?;
// Create a connection pool. This should be shared across your application.
let pool = Pool::builder(manager).build()?;
// Fetch and use a connection from the pool
let mut conn = pool.get().await?;
let response = conn.run("RETURN 1 as num;", None, None).await?;
let pull_meta = Metadata::from_iter(vec![("n", 1)]);
let (records, response) = conn.pull(Some(pull_meta)).await?;
assert_eq!(records[0].fields(), &[Value::from(1)]);
Ok(())
}
Re-exports§
pub use bolt_client;
pub use bolt_client::bolt_proto;
Structs§
- Manager
- Metrics
- Statistics regarding an object returned by the pool
- Pool
Config Pool
configuration.- Status
- The current pool status.
- Timeouts
- Timeouts when getting
Object
s from aPool
.
Enums§
- Runtime
- Enumeration for picking a runtime implementation.
Type Aliases§
- Build
Error - Type alias for using
deadpool::managed::BuildError
withbolt_client
. - Create
Pool Error - Type alias for using
deadpool::managed::CreatePoolError
withbolt_client
. - Hook
- Type alias for using
deadpool::managed::Hook
withbolt_client
. - Hook
Error - Type alias for using
deadpool::managed::HookError
withbolt_client
. - Hook
Error Cause - Type alias for using
deadpool::managed::HookErrorCause
withbolt_client
. - Object
- Type alias for using
deadpool::managed::Object
withbolt_client
. - Pool
- Type alias for using
deadpool::managed::Pool
withbolt_client
. - Pool
Builder - Type alias for using
deadpool::managed::PoolBuilder
withbolt_client
. - Pool
Error - Type alias for using
deadpool::managed::PoolError
withbolt_client
.