surreal_bb8

Crates.iosurreal_bb8
lib.rssurreal_bb8
version0.1.0
sourcesrc
created_at2023-11-26 10:24:53.539711
updated_at2023-11-26 10:24:53.539711
descriptionAn async connection pool for SurrealDB built on top of the bb8 library.
homepage
repositoryhttps://github.com/toadslop/surreal_bb8
max_upload_size
id1048953
size135,729
Brian (toadslop)

documentation

README

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.

Commit count: 11

cargo fmt