Skip to content

inzanez/mobc-arangors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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());
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages