pub struct Pool<C: ManageConnection + Send> { /* private fields */ }
Expand description
General connection pool
Implementations§
source§impl<C: ManageConnection> Pool<C>
impl<C: ManageConnection> Pool<C>
source§impl<C: ManageConnection + Send> Pool<C>
impl<C: ManageConnection + Send> Pool<C>
sourcepub async fn new(manager: C, config: Config) -> Result<Pool<C>, Error<C::Error>>
pub async fn new(manager: C, config: Config) -> Result<Pool<C>, Error<C::Error>>
Creates a new connection pool
The returned future will resolve to the pool if successful, which can then be used immediately.
sourcepub async fn connection(&self) -> Result<Conn<C>, Error<C::Error>>
pub async fn connection(&self) -> Result<Conn<C>, Error<C::Error>>
Returns a future that resolves to a connection from the pool.
If there are connections that are available to be used, the future will resolve immediately, otherwise, the connection will be in a pending state until a future is returned to the pool.
Timeout ability can be added to this method by calling connection_timeout
on the Config
.
sourcepub fn put_back(&self, conn: Live<C::Connection>)
pub fn put_back(&self, conn: Live<C::Connection>)
Receive a connection back to be stored in the pool. This could have one of two outcomes:
- The connection will be passed to a waiting future, if any exist.
- The connection will be put back into the connection pool.
sourcepub fn total_conns(&self) -> usize
pub fn total_conns(&self) -> usize
The total number of connections in the pool.
sourcepub fn idle_conns(&self) -> usize
pub fn idle_conns(&self) -> usize
The number of idle connections in the pool.
sourcepub fn idle_conns_push_error(&self) -> usize
pub fn idle_conns_push_error(&self) -> usize
The number of errors when the connection push back to the pool.
Trait Implementations§
source§impl<C> Clone for Pool<C>where
C: ManageConnection,
impl<C> Clone for Pool<C>where C: ManageConnection,
Returns a new Pool
referencing the same state as self
.