Crates.io | bb8-lapin |
lib.rs | bb8-lapin |
version | 0.5.0 |
source | src |
created_at | 2020-10-04 07:24:09.321374 |
updated_at | 2023-03-28 15:38:03.400591 |
description | r2d2-lapin, but for async tokio based connections |
homepage | |
repository | https://github.com/adrianbenavides/bb8-lapin |
max_upload_size | |
id | 295979 |
size | 50,029 |
Lapin support for the bb8 connection pool.
See the documentation of bb8 for the details on how to use the connection pool.
use bb8_lapin::prelude::*;
async fn example() {
let manager = LapinConnectionManager::new("amqp://guest:guest@127.0.0.1:5672//", ConnectionProperties::default());
let pool = bb8::Pool::builder()
.max_size(15)
.build(manager)
.await
.unwrap();
for _ in 0..20 {
let pool = pool.clone();
tokio::spawn(async move {
let conn = pool.get().await.unwrap();
// use the connection
// it will be returned to the pool when it falls out of scope.
});
}
}
See files in the examples folder for more examples.
The crate is tested on ubuntu-latest
against the nightly and stable rust versions.
It is possible that it works with older versions as well but this is not tested.
Please see the details of the bb8 and lapin crates about their requirements.