Skip to content

Commit 246b1c0

Browse files
committed
Expose PoolOptions for reading
This allows reading back PoolOptions that have already been set.
1 parent fa5c436 commit 246b1c0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

sqlx-core/src/pool/options.rs

+30
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ impl<DB: Database> PoolOptions<DB> {
6363
self
6464
}
6565

66+
/// Get the maximum number of connections that this pool should maintain
67+
pub fn get_max_connections(&self) -> u32 {
68+
self.max_connections
69+
}
70+
6671
/// Set the amount of time to attempt connecting to the database.
6772
///
6873
/// If this timeout elapses, [`Pool::acquire`] will return an error.
@@ -71,6 +76,11 @@ impl<DB: Database> PoolOptions<DB> {
7176
self
7277
}
7378

79+
/// Get the amount of time to attempt connecting to the database.
80+
pub fn get_connect_timeout(&self) -> Duration {
81+
self.connect_timeout
82+
}
83+
7484
/// Set the minimum number of connections to maintain at all times.
7585
///
7686
/// When the pool is built, this many connections will be automatically spun up.
@@ -85,6 +95,11 @@ impl<DB: Database> PoolOptions<DB> {
8595
self
8696
}
8797

98+
/// Get the minimum number of connections to maintain at all times.
99+
pub fn get_min_connections(&self) -> u32 {
100+
self.min_connections
101+
}
102+
88103
/// Set the maximum lifetime of individual connections.
89104
///
90105
/// Any connection with a lifetime greater than this will be closed.
@@ -104,6 +119,11 @@ impl<DB: Database> PoolOptions<DB> {
104119
self
105120
}
106121

122+
/// Get the maximum lifetime of individual connections.
123+
pub fn get_max_lifetime(&self) -> Option<Duration> {
124+
self.max_lifetime
125+
}
126+
107127
/// Set a maximum idle duration for individual connections.
108128
///
109129
/// Any connection with an idle duration longer than this will be closed.
@@ -114,6 +134,11 @@ impl<DB: Database> PoolOptions<DB> {
114134
self
115135
}
116136

137+
/// Get the maximum idle duration for individual connections.
138+
pub fn get_idle_timeout(&self) -> Option<Duration> {
139+
self.idle_timeout
140+
}
141+
117142
/// If true, the health of a connection will be verified by a call to [`Connection::ping`]
118143
/// before returning the connection.
119144
///
@@ -123,6 +148,11 @@ impl<DB: Database> PoolOptions<DB> {
123148
self
124149
}
125150

151+
/// Get's whether `test_before_acquire` is currently set.
152+
pub fn get_test_before_acquire(&self) -> bool {
153+
self.test_before_acquire
154+
}
155+
126156
/// If set to `true`, calls to `acquire()` are fair and connections are issued
127157
/// in first-come-first-serve order. If `false`, "drive-by" tasks may steal idle connections
128158
/// ahead of tasks that have been waiting.

0 commit comments

Comments
 (0)