pub struct RabbitMqPool { /* private fields */ }
Expand description
RabbitMQ connection pool which manages connection based on the amount of channels used per connection
Keeps a configured minimum of connections alive but creates them lazily when enough channels are requested
Implementations§
Source§impl RabbitMqPool
impl RabbitMqPool
Sourcepub fn from_config(
url: &str,
min_connections: u32,
max_channels_per_connection: u32,
) -> Arc<Self>
pub fn from_config( url: &str, min_connections: u32, max_channels_per_connection: u32, ) -> Arc<Self>
Creates a new RabbitMqPool
from given parameters
Spawns a connection reaper task on the tokio runtime
Sourcepub async fn make_connection(&self) -> Result<Connection, Error>
pub async fn make_connection(&self) -> Result<Connection, Error>
Create a connection with the pools given params
This just creates a connection and does not add it to its pool. Connections will automatically be created when creating channels.
Sourcepub async fn create_channel(&self) -> Result<RabbitMqChannel, Error>
pub async fn create_channel(&self) -> Result<RabbitMqChannel, Error>
Create a rabbitmq channel using one of the connections of the pool
If there are no connections available or all connections are at the channel cap a new connection will be created
Auto Trait Implementations§
impl !Freeze for RabbitMqPool
impl !RefUnwindSafe for RabbitMqPool
impl Send for RabbitMqPool
impl Sync for RabbitMqPool
impl Unpin for RabbitMqPool
impl !UnwindSafe for RabbitMqPool
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