Expose PoolOptions for reading (#2113)

This allows reading back PoolOptions that have already been set.
This commit is contained in:
Max Bruckner 2023-02-04 01:11:21 +01:00 committed by Austin Bonander
parent 5378dea6af
commit 092922e42a

View File

@ -141,6 +141,11 @@ impl<DB: Database> PoolOptions<DB> {
self self
} }
/// Get the maximum number of connections that this pool should maintain
pub fn get_max_connections(&self) -> u32 {
self.max_connections
}
/// Set the minimum number of connections to maintain at all times. /// Set the minimum number of connections to maintain at all times.
/// ///
/// When the pool is built, this many connections will be automatically spun up. /// When the pool is built, this many connections will be automatically spun up.
@ -168,6 +173,11 @@ impl<DB: Database> PoolOptions<DB> {
self self
} }
/// Get the minimum number of connections to maintain at all times.
pub fn get_min_connections(&self) -> u32 {
self.min_connections
}
/// Set the maximum amount of time to spend waiting for a connection in [`Pool::acquire()`]. /// Set the maximum amount of time to spend waiting for a connection in [`Pool::acquire()`].
/// ///
/// Caps the total amount of time `Pool::acquire()` can spend waiting across multiple phases: /// Caps the total amount of time `Pool::acquire()` can spend waiting across multiple phases:
@ -186,6 +196,11 @@ impl<DB: Database> PoolOptions<DB> {
self self
} }
/// Get the maximum amount of time to spend waiting for a connection in [`Pool::acquire()`].
pub fn get_acquire_timeout(&self) -> Duration {
self.acquire_timeout
}
/// Set the maximum lifetime of individual connections. /// Set the maximum lifetime of individual connections.
/// ///
/// Any connection with a lifetime greater than this will be closed. /// Any connection with a lifetime greater than this will be closed.
@ -205,6 +220,11 @@ impl<DB: Database> PoolOptions<DB> {
self self
} }
/// Get the maximum lifetime of individual connections.
pub fn get_max_lifetime(&self) -> Option<Duration> {
self.max_lifetime
}
/// Set a maximum idle duration for individual connections. /// Set a maximum idle duration for individual connections.
/// ///
/// Any connection that remains in the idle queue longer than this will be closed. /// Any connection that remains in the idle queue longer than this will be closed.
@ -215,6 +235,11 @@ impl<DB: Database> PoolOptions<DB> {
self self
} }
/// Get the maximum idle duration for individual connections.
pub fn get_idle_timeout(&self) -> Option<Duration> {
self.idle_timeout
}
/// If true, the health of a connection will be verified by a call to [`Connection::ping`] /// If true, the health of a connection will be verified by a call to [`Connection::ping`]
/// before returning the connection. /// before returning the connection.
/// ///
@ -224,6 +249,11 @@ impl<DB: Database> PoolOptions<DB> {
self self
} }
/// Get's whether `test_before_acquire` is currently set.
pub fn get_test_before_acquire(&self) -> bool {
self.test_before_acquire
}
/// If set to `true`, calls to `acquire()` are fair and connections are issued /// If set to `true`, calls to `acquire()` are fair and connections are issued
/// in first-come-first-serve order. If `false`, "drive-by" tasks may steal idle connections /// in first-come-first-serve order. If `false`, "drive-by" tasks may steal idle connections
/// ahead of tasks that have been waiting. /// ahead of tasks that have been waiting.