8 breaking releases
0.8.0 | Dec 28, 2022 |
---|---|
0.7.0 | Nov 24, 2021 |
0.6.1 | Mar 30, 2021 |
0.5.0 | Sep 18, 2020 |
0.2.0 | Jan 31, 2020 |
#811 in Asynchronous
235KB
4K
SLoC
bolt_client
support for the [bb8
] connection pool.
Example
use std::env;
use bb8_bolt::{
bb8::Pool,
bolt_client::Metadata,
bolt_proto::{version::*, Value},
Manager,
};
#[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().build(manager).await?;
// 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(())
}
Dependencies
~13–25MB
~430K SLoC