pub struct Pool<M>(/* private fields */)
where
M: ManageConnection;
r2d2
only.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,
impl<M> Clone for Pool<M>where
M: ManageConnection,
Returns a new Pool
referencing the same state as self
.