#connection-pool #surrealdb #bb8-connection #bb8 #async

surreal_bb8

An async connection pool for SurrealDB built on top of the bb8 library

1 unstable release

0.1.0 Nov 26, 2023

#2118 in Database interfaces

Download history 2/week @ 2024-02-14 8/week @ 2024-02-21 6/week @ 2024-02-28 1/week @ 2024-03-06 3/week @ 2024-03-13 3/week @ 2024-03-20 146/week @ 2024-03-27 9/week @ 2024-04-03

158 downloads per month

MIT/Apache

34KB
298 lines

SURREAL_BB8

Surreal_BB8 is an async connection pool for SurrealDB implemented on top of the BB8 library. Refer to the bb8 documentation for more information about how to use BB8 connection pools.

Usage

Basic Usage

use bb8::Pool;
use surreal_bb8::surreal::SurrealConnectionManager;
use surrealdb::engine::remote::mem::Mem;

let sur_mgr = SurrealConnectionManager::<_, Mem>::new(());

let pool = Pool::builder().build(sur_mgr).await.expect("build error");

let connection = pool.get().await.expect("pool error");

connection
   .health()
   .await
   .expect("Connection was not healthy");

println!("Connection is healthy")

With a configuration

use bb8::Pool;
use surreal_bb8::temp::{compiletime_with_config::SurrealConnectionManager, config::Config};
use surrealdb::{engine::remote::ws::Ws, opt::capabilities::Capabilities};

#[tokio::main]
async fn main() {
   let config = Config::new()
       .capabilities(Capabilities::default().with_guest_access(false))
       .strict();


   let sur_mgr: SurrealConnectionManager<Ws> =
       SurrealConnectionManager::new("127.0.0.1:8000", config);

   let pool = Pool::builder().build(sur_mgr).await.expect("build error");

   let connection = pool.get().await.expect("pool error");

   connection
       .health()
       .await
       .expect("Connection was not healthy");

   println!("Connection is healthy")
}

Issues

If you have an issue, please let us know here. If you have any improvements to make, please send us a PR.

Dependencies

~43–70MB
~1.5M SLoC