pub struct ConnectionPool<T: Driver, A: ConnectionAdapter<T>> { /* private fields */ }
Implementations§
Source§impl<T: Driver, A: ConnectionAdapter<T>> ConnectionPool<T, A>
impl<T: Driver, A: ConnectionAdapter<T>> ConnectionPool<T, A>
Sourcepub fn new(
config: ConnectionPoolConfig,
) -> Result<Arc<Self>, ConnectionPoolError<T::ConnectionError>>
pub fn new( config: ConnectionPoolConfig, ) -> Result<Arc<Self>, ConnectionPoolError<T::ConnectionError>>
Create a new connection pool with the given config
.
The write connection is created first, followed by a read connection for every reader.
§Errors
Returns error if the connections could not be initialized.
Sourcepub fn connection(
self: &Arc<Self>,
) -> Result<PooledConnection<T, A>, ConnectionPoolError<T::Error>>
pub fn connection( self: &Arc<Self>, ) -> Result<PooledConnection<T, A>, ConnectionPoolError<T::Error>>
Retrieve a connection from the pool.
If all the connections are currently in use, we will wait until one is returned to the
pool. If ConnectionPoolConfig.connection_acquire_timeout
has no value, this method will
block indefinitely.
§Errors
Return error if we could not retrieve a connection from the pool before the timeout triggered.
Auto Trait Implementations§
impl<T, A> !Freeze for ConnectionPool<T, A>
impl<T, A> !RefUnwindSafe for ConnectionPool<T, A>
impl<T, A> Send for ConnectionPool<T, A>
impl<T, A> Sync for ConnectionPool<T, A>
impl<T, A> Unpin for ConnectionPool<T, A>
impl<T, A> UnwindSafe for ConnectionPool<T, A>
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