pub struct LapinConnectionManager { /* private fields */ }Expand description
An r2d2::ManageConnection for lapin::Connections.
§Example
use lapin::ConnectionProperties;
use r2d2_lapin::prelude::*;
use std::thread;
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.
});
}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
Initialise the connection manager with the data needed to create new connections.
Refer to the documentation of lapin::ConnectionProperties for further details on the parameters.
§Example
let manager = r2d2_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§fn connect(&self) -> Result<Self::Connection, Self::Error>
fn connect(&self) -> Result<Self::Connection, Self::Error>
Attempts to create a new connection.
Source§fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>
fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>
Determines if the connection is still connected to the database. Read more
Source§fn has_broken(&self, conn: &mut Self::Connection) -> bool
fn has_broken(&self, conn: &mut Self::Connection) -> bool
Quickly determines if the connection is no longer usable. Read more
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<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