Struct r2d2_couchdb::CouchdbConnectionManager
[−]
[src]
pub struct CouchdbConnectionManager { // some fields omitted }
An r2d2::ManageConnection
for
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() } }
Methods
impl CouchdbConnectionManager
[src]
fn new(server_url: &str) -> Result<CouchdbConnectionManager, Error>
Creates a new CouchdbConnectionManager
.
Trait Implementations
impl ManageConnection for CouchdbConnectionManager
[src]
type Connection = Client
The connection type this manager deals with.
type Error = Error
The error type returned by Connection
s.
fn connect(&self) -> Result<Client, Error>
Attempts to create a new connection.
fn is_valid(&self, _conn: &mut Client) -> Result<(), Error>
Determines if the connection is still connected to the database. Read more
fn has_broken(&self, _conn: &mut Client) -> bool
Quickly determines if the connection is no longer usable. Read more