Crates.io | r2d2-lapin |
lib.rs | r2d2-lapin |
version | 0.2.2 |
source | src |
created_at | 2020-09-25 13:39:04.443763 |
updated_at | 2020-11-19 08:59:18.016392 |
description | Lapin support for the r2d2 connection pool |
homepage | |
repository | https://github.com/adrianbenavides/r2d2-lapin |
max_upload_size | |
id | 292836 |
size | 12,286 |
NOTE: This project has been archived. Consider using the bb8 or mobc connection managers.
Lapin support for the r2d2 connection pool.
See the documentation of r2d2 for the details on how to use the connection pool.
use lapin::ConnectionProperties;
use r2d2_lapin::LapinConnectionManager;
use std::thread;
fn main() {
let manager = LapinConnectionManager::new("amqp://guest:guest@127.0.0.1:5672//", &ConnectionProperties::default());
let pool = r2d2::Pool::builder()
.max_size(15)
.build(manager)
.unwrap();
for _ in 0..20 {
let pool = pool.clone();
thread::spawn(move || {
let conn = pool.get().unwrap();
// use the connection
// it will be returned to the pool when it falls out of scope.
});
}
}
The crate is tested on ubuntu-latest
against the following rust versions: nightly, beta, stable and 1.45.0.
It is possible that it works with older versions as well but this is not tested.
Please see the details of the r2d2 and lapin crates about their requirements.