https://github.com/scorphus/r2d2-couchdb
🛋 CouchDB support for the r2d2 connection pool
https://github.com/scorphus/r2d2-couchdb
couchdb r2d2
Last synced: about 1 year ago
JSON representation
🛋 CouchDB support for the r2d2 connection pool
- Host: GitHub
- URL: https://github.com/scorphus/r2d2-couchdb
- Owner: scorphus
- License: apache-2.0
- Created: 2016-06-23T04:21:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-30T23:11:18.000Z (almost 10 years ago)
- Last Synced: 2025-03-18T14:53:46.199Z (about 1 year ago)
- Topics: couchdb, r2d2
- Language: Rust
- Homepage: https://scorphus.github.io/r2d2-couchdb
- Size: 5.45 MB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# r2d2-couchdb [![Build Status][travis-badge]][travis-link] [![MIT License][mit-license-badge]](LICENSE-MIT) [![Apache 2.0][apache-2.0-badge]](LICENSE-APACHE)
[CouchDB] support library for the [r2d2](https://github.com/sfackler/r2d2) connection pool. Read the [documentation].
# Example
```rust
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()
}
}
```
[travis-badge]: https://img.shields.io/travis/scorphus/r2d2-couchdb.svg
[travis-link]: https://travis-ci.org/scorphus/r2d2-couchdb
[mit-license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg
[apache-2.0-badge]: https://img.shields.io/badge/license-Apache%202.0-007EC7.svg
[CouchDB]: https://github.com/chill-rs/chill
[documentation]: https://scorphus.github.io/r2d2-couchdb/