pub struct LapinConnectionManager { /* private fields */ }Expand description
A bb8::ManageConnection implementation for lapin::Connections.
§Example
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.
});
}
}Implementations§
Source§impl LapinConnectionManager
impl LapinConnectionManager
Sourcepub fn new(amqp_address: &str, conn_properties: ConnectionProperties) -> Self
pub fn new(amqp_address: &str, conn_properties: ConnectionProperties) -> Self
Initialize the connection manager with the data needed to create new connections.
Refer to the documentation of lapin::ConnectionProperties
for further details on the available connection parameters.
§Example
let manager = bb8_lapin::LapinConnectionManager::new("amqp://guest:guest@127.0.0.1:5672//", lapin::ConnectionProperties::default());Trait Implementations§
Source§impl Debug for LapinConnectionManager
impl Debug for LapinConnectionManager
Source§impl ManageConnection for LapinConnectionManager
impl ManageConnection for LapinConnectionManager
Source§type Connection = Connection
type Connection = Connection
The connection type this manager deals with.
Source§async fn connect(&self) -> Result<Self::Connection, Self::Error>
async fn connect(&self) -> Result<Self::Connection, Self::Error>
Attempts to create a new connection.
Source§async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>
async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>
Determines if the connection is still connected to the database.
Source§fn has_broken(&self, conn: &mut Self::Connection) -> bool
fn has_broken(&self, conn: &mut Self::Connection) -> bool
Synchronously determine if the connection is no longer usable, if possible.
Auto Trait Implementations§
impl Freeze for LapinConnectionManager
impl !RefUnwindSafe for LapinConnectionManager
impl Send for LapinConnectionManager
impl Sync for LapinConnectionManager
impl Unpin for LapinConnectionManager
impl !UnwindSafe for LapinConnectionManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more