#r2d2 #database #mongo #mongodb #pool

r2d2-mongodb

A MongoDB adaptor for r2d2 connection pool

7 releases

Uses old Rust 2015

0.2.2 Jan 9, 2019
0.2.1 Jan 8, 2019
0.2.0 Dec 4, 2018
0.1.3 Jun 29, 2018

#10 in #mongo

Download history 91/week @ 2021-08-11 62/week @ 2021-08-18 45/week @ 2021-08-25 19/week @ 2021-09-01 50/week @ 2021-09-08 28/week @ 2021-09-15 32/week @ 2021-09-22 47/week @ 2021-09-29 19/week @ 2021-10-06 40/week @ 2021-10-13 25/week @ 2021-10-20 27/week @ 2021-10-27 36/week @ 2021-11-03 14/week @ 2021-11-10 17/week @ 2021-11-17 27/week @ 2021-11-24

97 downloads per month
Used in 2 crates

GPL-3.0 license

16KB
189 lines

crates.io docs.rs

r2d2-mongodb

A MongoDB adaptor for r2d2 connection pool.

Documentation

In progress...

Example usage

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

    // ...
}

Dependencies

~11MB
~247K SLoC