pub struct Pool<M>(/* private fields */)
where
M: ManageConnection;
Expand description
A generic connection pool.
Implementations§
Source§impl<M> Pool<M>where
M: ManageConnection,
impl<M> Pool<M>where
M: ManageConnection,
Sourcepub fn new(manager: M) -> Result<Pool<M>, Error>
pub fn new(manager: M) -> Result<Pool<M>, Error>
Creates a new connection pool with a default configuration.
Sourcepub fn get(&self) -> Result<PooledConnection<M>, Error>
pub fn get(&self) -> Result<PooledConnection<M>, Error>
Retrieves a connection from the pool.
Waits for at most the configured connection timeout before returning an error.
Sourcepub fn get_timeout(
&self,
timeout: Duration,
) -> Result<PooledConnection<M>, Error>
pub fn get_timeout( &self, timeout: Duration, ) -> Result<PooledConnection<M>, Error>
Retrieves a connection from the pool, waiting for at most timeout
The given timeout will be used instead of the configured connection timeout.
Sourcepub fn try_get(&self) -> Option<PooledConnection<M>>
pub fn try_get(&self) -> Option<PooledConnection<M>>
Attempts to retrieve a connection from the pool if there is one available.
Returns None
if there are no idle connections available in the pool.
This method will not block waiting to establish a new connection.
Sourcepub fn test_on_check_out(&self) -> bool
pub fn test_on_check_out(&self) -> bool
Returns if the pool is configured to test connections on check out.
Sourcepub fn max_lifetime(&self) -> Option<Duration>
pub fn max_lifetime(&self) -> Option<Duration>
Returns the configured maximum connection lifetime.
Sourcepub fn idle_timeout(&self) -> Option<Duration>
pub fn idle_timeout(&self) -> Option<Duration>
Returns the configured idle connection timeout.
Sourcepub fn connection_timeout(&self) -> Duration
pub fn connection_timeout(&self) -> Duration
Returns the configured connection timeout.
Trait Implementations§
Source§impl<M> Clone for Pool<M>where
M: ManageConnection,
Returns a new Pool
referencing the same state as self
.
impl<M> Clone for Pool<M>where
M: ManageConnection,
Returns a new Pool
referencing the same state as self
.