Skip to content

A bb8 connection pool implementation for SurrealDB

Notifications You must be signed in to change notification settings

toadslop/surreal_bb8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A bb8 connection pool implementation for SurrealDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages