[][src]Struct sqlx::pool::Builder

pub struct Builder<C> { /* fields omitted */ }

Builder for Pool.

Methods

impl<C> Builder<C>[src]

pub fn max_size(self, max_size: u32) -> Builder<C>[src]

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

pub fn connect_timeout(self, connect_timeout: Duration) -> Builder<C>[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) -> Builder<C>[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>>
) -> Builder<C>
[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>>
) -> Builder<C>
[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 fn test_on_acquire(self, test: bool) -> Builder<C>[src]

If true, the health of a connection will be verified by a call to Connection::ping before returning the connection.

Defaults to true.

pub async fn build(self, url: &'_ str) -> Result<Pool<C>, Error> where
    C: Connection + Connect<Connection = C>, 
[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<C> Default for Builder<C>[src]

Auto Trait Implementations

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

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

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

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

impl<C> UnwindSafe for Builder<C> where
    C: 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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,