Struct Builder

Source
pub struct Builder { /* private fields */ }

Implementations§

Source§

impl Builder

Source

pub fn new() -> Builder

Source

pub fn max_size(self, max_size: usize) -> Builder

Source

pub fn min_idle(self, min_idle: usize) -> Builder

Source

pub fn always_check(self, always_check: bool) -> Builder

If true, the health of a connection will be verified when checkout.

This check uses Builder’s connection_timeout setting to cancel the check and return a timeout error.

Defaults to true.

Source

pub fn use_gc(self, use_gc: bool) -> Builder

If true, the pending connections that last for too long will be removed.( 6 times the connection_timeout duration)

This is a placeholder feature. it works fine but in most cases it’s not necessary or useful.

Defaults to false.

Source

pub fn max_lifetime(self, max_lifetime: Option<Duration>) -> Builder

Sets the maximum lifetime of connections in the pool.

If set, connections will be closed at the next reaping after surviving past this duration.

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.

Source

pub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Builder

Sets the idle timeout used by the pool.

If set, idle connections in excess of min_idle will be closed at the next reaping after remaining idle past this duration.

Defaults to 10 minutes.

Source

pub fn reaper_rate(self, reaper_rate: Duration) -> Builder

Sets the connection reaper rate.

The connection that are idle and live beyond the time gate will be dropped.

Default 15 seconds.(no guarantee as we don’t force lock the pool)

Source

pub fn connection_timeout(self, connection_timeout: Duration) -> Builder

Sets the connection timeout used by the pool.

Attempt to establish new connection to database will be canceled and return a timeout error if this Duration passed.

It’s recommended to set this duration the same or a bit longer than your database connection timeout setting.

Default 10 seconds.

Source

pub fn wait_timeout(self, wait_timeout: Duration) -> Builder

Sets the wait timeout used by the queue.

Similar to connection_timeout. A timeout error will return if we wait too long for a connection from pool.

Default 20 seconds

Source

pub async fn build<M: Manager>(self, manager: M) -> Result<Pool<M>, M::Error>

Consumes the Builder, returning a new, initialized Pool.

Source

pub fn build_uninitialized<M: Manager>(self, manager: M) -> Pool<M>

Consumes the Builder, returning a new uninitialized Pool.

(Pool have no connection and scheduled tasks like connection reaper and garbage collect)

Source

pub fn get_reaper_rate(&self) -> Duration

expose reaper_rate to public.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.