Crates.io | r2d2-jfs |
lib.rs | r2d2-jfs |
version | 0.2.0 |
source | src |
created_at | 2019-08-30 11:10:05.214109 |
updated_at | 2021-10-25 12:28:43.788334 |
description | JFS support for the r2d2 connection pool |
homepage | |
repository | https://github.com/flosse/r2d2-jfs |
max_upload_size | |
id | 160846 |
size | 6,042 |
JSON file store (jfs
) support for the
r2d2
connection pool.
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