pub struct ConnectionPool { /* private fields */ }Expand description
A pool of database connections.
Connections are recycled via an unbounded mpsc channel. When a PooledConnection
is dropped, its inner Arc<Connection> is sent back through the channel so
subsequent get() calls can reuse it instead of opening a new connection.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub async fn new(config: PoolConfig) -> Result<Self, ClientError>
pub async fn new(config: PoolConfig) -> Result<Self, ClientError>
Create a new connection pool.
Sourcepub async fn with_connection_config(
config: PoolConfig,
connection_config: ConnectionConfig,
) -> Result<Self, ClientError>
pub async fn with_connection_config( config: PoolConfig, connection_config: ConnectionConfig, ) -> Result<Self, ClientError>
Create a pool with specific connection configuration.
Sourcepub async fn get(&self) -> Result<PooledConnection, ClientError>
pub async fn get(&self) -> Result<PooledConnection, ClientError>
Get a connection from the pool.
Sourcepub async fn return_connection(&self, conn: Arc<Connection>)
pub async fn return_connection(&self, conn: Arc<Connection>)
Return a connection to the pool (explicit async path).
Sourcepub async fn is_healthy(&self) -> bool
pub async fn is_healthy(&self) -> bool
Check if the pool is healthy.
Auto Trait Implementations§
impl !Freeze for ConnectionPool
impl !RefUnwindSafe for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl UnsafeUnpin for ConnectionPool
impl !UnwindSafe for ConnectionPool
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