[−][src]Struct sqlx::pool::Builder
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]
self,
max_lifetime: impl Into<Option<Duration>>
) -> Builder<C>
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]
self,
idle_timeout: impl Into<Option<Duration>>
) -> Builder<C>
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]
C: Connection + Connect<Connection = C>,
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
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, DB> HasSqlType<&'_ T> for DB where
DB: HasSqlType<T>,
T: ?Sized,
[src]
DB: HasSqlType<T>,
T: ?Sized,
impl<T, DB> HasSqlType<Option<T>> for DB where
DB: HasSqlType<T>,
[src]
DB: HasSqlType<T>,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,