Crates.io | mobc-arangors |
lib.rs | mobc-arangors |
version | 0.2.2 |
source | src |
created_at | 2020-06-04 11:28:55.368072 |
updated_at | 2020-09-04 11:42:18.681209 |
description | ArangoDB support for the async mobc connection pool |
homepage | |
repository | https://github.com/inzanez/mobc-arangors |
max_upload_size | |
id | 249968 |
size | 63,362 |
Implementation of async connection pool for arangors
using mobc
. Currently only reqwest
is support as a client.
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());
}