pub struct Builder<M>where
M: ManageConnection,{
pub max_lifetime: Option<Duration>,
pub idle_timeout: Option<Duration>,
pub connection_timeout: Option<Duration>,
pub max_size: u32,
pub check_interval: Option<Duration>,
/* private fields */
}
Expand description
A builder for a connection pool.
Fields§
§max_lifetime: Option<Duration>
§idle_timeout: Option<Duration>
§connection_timeout: Option<Duration>
§max_size: u32
§check_interval: Option<Duration>
Implementations§
Source§impl<M> Builder<M>where
M: ManageConnection,
impl<M> Builder<M>where
M: ManageConnection,
Sourcepub fn max_lifetime(self, max_lifetime: Option<Duration>) -> Self
pub fn max_lifetime(self, max_lifetime: Option<Duration>) -> Self
Sets the maximum lifetime of connections in the pool.
If a connection reaches its maximum lifetime while checked out it will be closed when it is returned to the pool.
Defaults to 30 minutes.
use default if max_lifetime
is the zero Duration
.
Sourcepub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Self
pub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Self
Sets the idle timeout used by the pool.
If set, connections will be closed after exceed idle time.
Defaults to 3 minutes.
use default if idle_timeout
is the zero Duration
.
Sourcepub fn connection_timeout(self, connection_timeout: Option<Duration>) -> Self
pub fn connection_timeout(self, connection_timeout: Option<Duration>) -> Self
Sets the connection timeout used by the pool.
Calls to Pool::get
will wait this long for a connection to become
available before returning an error.
Defaults to 3 seconds.
don’t timeout if connection_timeout
is the zero duration
Sourcepub fn max_size(self, max_size: u32) -> Self
pub fn max_size(self, max_size: u32) -> Self
Sets the maximum number of connections managed by the pool.
Defaults to 10.
no limited if max_size
is 0.
Sourcepub fn check_interval(self, interval: Option<Duration>) -> Self
pub fn check_interval(self, interval: Option<Duration>) -> Self
Sets the check interval of connections managed by the pool use the ManageConnection::check
.
Defaults to 3s.
Sourcepub fn build(&self, manager: M) -> Pool<M>where
M: ManageConnection,
pub fn build(&self, manager: M) -> Pool<M>where
M: ManageConnection,
Consumes the builder, returning a new, initialized pool.