[][src]Struct sqlx_core::pool::Builder

pub struct Builder<DB> where
    DB: Database
{ /* fields omitted */ }

Builder for Pool.

Methods

impl<DB> Builder<DB> where
    DB: Database
[src]

pub fn new() -> Self[src]

Get a new builder with default options.

See the source of this method for current defaults.

pub fn max_size(self, max_size: u32) -> Self[src]

Set the maximum number of connections that this pool should maintain.

pub fn connect_timeout(self, connect_timeout: Duration) -> Self[src]

Set the amount of time to attempt connecting to the database.

If this timeout elapses, Pool::acquire will return an error.

pub fn min_size(self, min_size: u32) -> Self[src]

Set the minimum number of connections to maintain at all times.

When the pool is built, this many connections will be automatically spun up.

If any connection is reaped by [max_lifetime] or [idle_timeout] and it brings the connection count below this amount, a new connection will be opened to replace it.

pub fn max_lifetime(self, max_lifetime: impl Into<Option<Duration>>) -> Self[src]

Set the maximum lifetime of individual connections.

Any connection with a lifetime greater than this will be closed.

When set to None, all connections live until either reaped by [idle_timeout] or explicitly disconnected.

Infinite connections are not recommended due to the unfortunate reality of memory/resource leaks on the database-side. It is better to retire connections periodically (even if only once daily) to allow the database the opportunity to clean up data structures (parse trees, query metadata caches, thread-local storage, etc.) that are associated with a session.

pub fn idle_timeout(self, idle_timeout: impl Into<Option<Duration>>) -> Self[src]

Set a maximum idle duration for individual connections.

Any connection with an idle duration longer than this will be closed.

For usage-based database server billing, this can be a cost saver.

pub async fn build<'_>(self, url: &'_ str) -> Result<Pool<DB>>[src]

Spin up the connection pool.

If [min_size] was set to a non-zero value, that many connections will be immediately opened and placed into the pool.

Trait Implementations

impl<DB> Default for Builder<DB> where
    DB: Database
[src]

Auto Trait Implementations

impl<DB> RefUnwindSafe for Builder<DB> where
    DB: RefUnwindSafe

impl<DB> Send for Builder<DB> where
    DB: Send

impl<DB> Sync for Builder<DB> where
    DB: Sync

impl<DB> Unpin for Builder<DB> where
    DB: Unpin

impl<DB> UnwindSafe for Builder<DB> where
    DB: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<'_, T, DB> HasSqlType<&'_ T> for DB where
    DB: HasSqlType<T>,
    T: ?Sized
[src]

impl<T, DB> HasSqlType<Option<T>> for DB where
    DB: HasSqlType<T>, 
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.