https://github.com/flosse/r2d2-jfs
https://github.com/flosse/r2d2-jfs
file jfs json r2d2
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/flosse/r2d2-jfs
- Owner: flosse
- Created: 2019-08-29T22:15:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-25T12:28:56.000Z (over 4 years ago)
- Last Synced: 2024-10-05T04:41:04.789Z (over 1 year ago)
- Topics: file, jfs, json, r2d2
- Language: Rust
- Size: 2.93 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# r2d2-jfs
## r2d2-jfs
[JSON file store (`jfs`)](https://crates.io/crates/jfs) support for the
[`r2d2`](https://crates.io/crates/r2d2) connection pool.
### Example
```rust
use std::thread;
use serde::{Serialize, Deserialize};
use r2d2_jfs::JfsConnectionManager;
#[derive(Serialize, Deserialize)]
struct Data { x: i32 }
fn main() {
let manager = JfsConnectionManager::file("file.json").unwrap();
let pool = r2d2::Pool::builder().max_size(5).build(manager).unwrap();
let mut threads = vec![];
for i in 0..10 {
let pool = pool.clone();
threads.push(thread::spawn(move || {
let d = Data { x: i };
let conn = pool.get().unwrap();
conn.save(&d).unwrap();
}));
}
for c in threads {
c.join().unwrap();
}
}
```
License: Apache-2.0 OR MIT