r2d2-jfs

Crates.ior2d2-jfs
lib.rsr2d2-jfs
version0.2.0
sourcesrc
created_at2019-08-30 11:10:05.214109
updated_at2021-10-25 12:28:43.788334
descriptionJFS support for the r2d2 connection pool
homepage
repositoryhttps://github.com/flosse/r2d2-jfs
max_upload_size
id160846
size6,042
Markus Kohlhase (flosse)

documentation

https://docs.rs/r2d2-jfs/

README

r2d2-jfs

r2d2-jfs

JSON file store (jfs) support for the r2d2 connection pool.

Example

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

Commit count: 4

cargo fmt