pub struct AsyncConnectionPool<T, F>(/* private fields */);Expand description
A tokio-based, cancel-safe connection pool. Cheaply clonable (clones share one pool).
Implementations§
Source§impl<T, F> AsyncConnectionPool<T, F>
impl<T, F> AsyncConnectionPool<T, F>
Sourcepub fn new(
factory: F,
config: PoolConfig,
options: Option<PoolOptions<T>>,
) -> Result<Self, PoolError>
pub fn new( factory: F, config: PoolConfig, options: Option<PoolOptions<T>>, ) -> Result<Self, PoolError>
Builds an async pool, validating config.
Sourcepub async fn open(&self) -> Result<(), PoolError>
pub async fn open(&self) -> Result<(), PoolError>
Warms up min_size connections and starts background maintenance. Idempotent.
Sourcepub async fn close(&self, timeout: Option<f64>)
pub async fn close(&self, timeout: Option<f64>)
Closes idle connections now; checked-out ones close on release. Idempotent. timeout
(None = don’t wait) drains gracefully up to that many seconds.
Sourcepub async fn acquire(&self, timeout: Timeout) -> Result<T, PoolError>
pub async fn acquire(&self, timeout: Timeout) -> Result<T, PoolError>
Gets a connection, honoring cancellation (drop the future) and the acquire timeout.
Sourcepub async fn release(&self, conn: T) -> Result<(), PoolError>
pub async fn release(&self, conn: T) -> Result<(), PoolError>
Returns a connection to the pool for reuse.
Sourcepub async fn discard(&self, conn: T) -> Result<(), PoolError>
pub async fn discard(&self, conn: T) -> Result<(), PoolError>
Returns a connection but forces it to be closed instead of reused.
Sourcepub async fn release_with_error(
&self,
conn: T,
error: &(dyn Error + 'static),
) -> Result<(), PoolError>
pub async fn release_with_error( &self, conn: T, error: &(dyn Error + 'static), ) -> Result<(), PoolError>
Returns a connection, signalling the caller’s work raised error.
Sourcepub async fn run_maintenance(&self)
pub async fn run_maintenance(&self)
Performs one maintenance sweep (see ConnectionPool::run_maintenance).
Trait Implementations§
Auto Trait Implementations§
impl<T, F> !RefUnwindSafe for AsyncConnectionPool<T, F>
impl<T, F> !UnwindSafe for AsyncConnectionPool<T, F>
impl<T, F> Freeze for AsyncConnectionPool<T, F>
impl<T, F> Send for AsyncConnectionPool<T, F>
impl<T, F> Sync for AsyncConnectionPool<T, F>
impl<T, F> Unpin for AsyncConnectionPool<T, F>
impl<T, F> UnsafeUnpin for AsyncConnectionPool<T, F>where
Arc<Inner<T, F>>: UnsafeUnpin,
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