bb8-surrealdb

Crates.iobb8-surrealdb
lib.rsbb8-surrealdb
version0.1.3
sourcesrc
created_at2022-10-27 11:18:04.894811
updated_at2022-11-09 01:57:46.831377
descriptionSurrealDB driver for bb8 based on the surrealdb crate
homepage
repositoryhttps://github.com/blakeanedved/bb8-surrealdb
max_upload_size
id699073
size6,761
Blake Nedved (blakeanedved)

documentation

README

bb8-surrealdb

SurrealDB support for bb8 based on the surrealdb crate.

Installing

Make sure to add bb8 and bb8-surrealdb to your Cargo.toml, like:

[dependencies]
bb8 = "0.8"
bb8-surrealdb = "0.1.2"
surrealdb = "1.0.0-beta.8"

Example

use bb8::Pool;
use bb8_surrealdb::SurrealdbConnectionManager;
use surrealdb::Session;
use futures_util::join_all;

#[tokio::main]
async fn main() {
    let pool = Pool::builder()
        .max_size(5)
        .build(
            SurrealdbConnectionManager::tikv(
                "localhost:2379",
                Session::for_kv().with_ns("test").with_db("test")
            ).await
        )
        .await
        .unwrap();

    for _i in 0..10 {
        let pool = pool.clone();

        handles.push(tokio::spawn(async move {
            let conn = pool.get().await.unwrap();

            conn.execute("SELECT * from user;", None, false).await.unwrap();
        }))
    }

    join_all(handles).await;
}

Important Note

This crate is really only useful if compiling with the tikv feature, as you cannot have multiple instances of a connection to an in memory embedded database or multiple instances of a connection to a file based store due to file locks. This feature has not been included by default to allow compilation as the surreal crate with the tikv feature does not compile on windows, and only compiles on other platforms if GCC 8 specifically is installed.

License

bb8-surrealdb is primarily distributed under the terms of the MIT license.

See LICENSE for details.

Commit count: 5

cargo fmt