mobc-arangors

Crates.iomobc-arangors
lib.rsmobc-arangors
version0.2.2
sourcesrc
created_at2020-06-04 11:28:55.368072
updated_at2020-09-04 11:42:18.681209
descriptionArangoDB support for the async mobc connection pool
homepage
repositoryhttps://github.com/inzanez/mobc-arangors
max_upload_size
id249968
size63,362
inzanez (inzanez)

documentation

README

mobc-arangors

Implementation of async connection pool for arangors using mobc. Currently only reqwest is support as a client.

Example

use mobc::Pool;
use std::time::Instant;
use mobc_arangors::ArangoDBConnectionManager;

#[tokio::main]
async fn main() {
    let manager = ArangoDBConnectionManager::new("http://arangoserver/", "root", "password", true);
    let pool = Pool::builder().max_open(20).build(manager);
    const MAX: usize = 100;

    let now = Instant::now();
    let (tx, mut rx) = tokio::sync::mpsc::channel::<usize>(16);
    for i in 0..MAX {
        let pool = pool.clone();
        let mut tx_c = tx.clone();
        tokio::spawn(async move {

            let client = pool.get().await.unwrap();
            let db = client.db("_system").await.unwrap();

            let version = db.arango_version().await.unwrap().version;
            assert_eq!(version, "3.6.2");
            tx_c.send(i).await.unwrap();
        });
    }

    for _ in 0..MAX {
        rx.recv().await.unwrap();
    }

    println!("cost: {:?}", now.elapsed());
}
Commit count: 17

cargo fmt