Skip to content

🛋 CouchDB support for the r2d2 connection pool

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

scorphus/r2d2-couchdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

r2d2-couchdb Build Status MIT License Apache 2.0

CouchDB support library for the r2d2 connection pool. Read the documentation.

Example

extern crate r2d2;
extern crate r2d2_couchdb;
extern crate serde_json;

use r2d2_couchdb::{CouchdbConnectionManager};

use std::thread;

fn main() {
    let config = r2d2::Config::default();
    let manager = CouchdbConnectionManager::new("http://localhost:5984/").unwrap();
    let pool = r2d2::Pool::new(config, manager).unwrap();

    let mut handles = vec![];

    for i in 0..20 {
        let pool = pool.clone();
        handles.push(thread::spawn(move || {
            let content = serde_json::builder::ObjectBuilder::new()
                .insert("foo", i)
                .unwrap();
            println!("Sending {}", &content);
            let conn = pool.get().unwrap();
            conn.create_document("/test", &content).run().unwrap();
        }));
    }

    for handle in handles {
        handle.join().unwrap()
    }
}

About

🛋 CouchDB support for the r2d2 connection pool

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages