Crates.io | r2d2-mongodb |
lib.rs | r2d2-mongodb |
version | 0.2.2 |
source | src |
created_at | 2018-06-24 16:45:48.686872 |
updated_at | 2019-01-09 18:37:01.88573 |
description | A MongoDB adaptor for r2d2 connection pool |
homepage | |
repository | https://gitlab.com/petoknm/r2d2-mongodb |
max_upload_size | |
id | 71494 |
size | 45,221 |
A MongoDB adaptor for r2d2 connection pool.
Start mongodb:
$ docker run --rm -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=password -e MONGO_INITDB_DATABASE=mydb mongo:latest
extern crate r2d2;
extern crate r2d2_mongodb;
use r2d2::Pool;
use r2d2_mongodb::{ConnectionOptions, MongodbConnectionManager};
fn main () {
let manager = MongodbConnectionManager::new(
ConnectionOptions::builder()
.with_host("localhost", 27017)
.with_db("mydb")
.with_auth("root", "password")
.build()
);
let pool = Pool::builder()
.max_size(16)
.build(manager)
.unwrap();
// ...
}