[−][src]Struct sqlx_core::pool::Builder
Builder for Pool.
Methods
impl<C> Builder<C> where
C: Connect, [src]
C: Connect,
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 fn test_on_acquire(self, test: bool) -> Self[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>> where
C: Connect, [src]
C: Connect,
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, DB> Default for Builder<C> where
C: Connect<Database = DB>,
DB: Database<Connection = C>, [src]
C: Connect<Database = DB>,
DB: Database<Connection = C>,
Auto Trait Implementations
impl<C> RefUnwindSafe for Builder<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for Builder<C> where
C: Send,
C: Send,
impl<C> Sync for Builder<C> where
C: Sync,
C: Sync,
impl<C> Unpin for Builder<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for Builder<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,