Skip to content

Commit c7282fe

Browse files
committed
Expose PoolOptions for reading
This allows reading back PoolOptions that have already been set.
1 parent 76ae286 commit c7282fe

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
@@ -141,6 +141,11 @@ impl<DB: Database> PoolOptions<DB> {
141141
self
142142
}
143143

144+
/// Get the maximum number of connections that this pool should maintain
145+
pub fn get_max_connections(&self) -> u32 {
146+
self.max_connections
147+
}
148+
144149
/// Set the minimum number of connections to maintain at all times.
145150
///
146151
/// When the pool is built, this many connections will be automatically spun up.
@@ -168,6 +173,11 @@ impl<DB: Database> PoolOptions<DB> {
168173
self
169174
}
170175

176+
/// Get the minimum number of connections to maintain at all times.
177+
pub fn get_min_connections(&self) -> u32 {
178+
self.min_connections
179+
}
180+
171181
/// Set the maximum amount of time to spend waiting for a connection in [`Pool::acquire()`].
172182
///
173183
/// Caps the total amount of time `Pool::acquire()` can spend waiting across multiple phases:
@@ -186,6 +196,11 @@ impl<DB: Database> PoolOptions<DB> {
186196
self
187197
}
188198

199+
/// Get the maximum amount of time to spend waiting for a connection in [`Pool::acquire()`].
200+
pub fn get_acquire_timeout(&self) -> Duration {
201+
self.acquire_timeout
202+
}
203+
189204
/// Set the maximum lifetime of individual connections.
190205
///
191206
/// Any connection with a lifetime greater than this will be closed.
@@ -205,6 +220,11 @@ impl<DB: Database> PoolOptions<DB> {
205220
self
206221
}
207222

223+
/// Get the maximum lifetime of individual connections.
224+
pub fn get_max_lifetime(&self) -> Option<Duration> {
225+
self.max_lifetime
226+
}
227+
208228
/// Set a maximum idle duration for individual connections.
209229
///
210230
/// Any connection that remains in the idle queue longer than this will be closed.
@@ -215,6 +235,11 @@ impl<DB: Database> PoolOptions<DB> {
215235
self
216236
}
217237

238+
/// Get the maximum idle duration for individual connections.
239+
pub fn get_idle_timeout(&self) -> Option<Duration> {
240+
self.idle_timeout
241+
}
242+
218243
/// If true, the health of a connection will be verified by a call to [`Connection::ping`]
219244
/// before returning the connection.
220245
///
@@ -224,6 +249,11 @@ impl<DB: Database> PoolOptions<DB> {
224249
self
225250
}
226251

252+
/// Get's whether `test_before_acquire` is currently set.
253+
pub fn get_test_before_acquire(&self) -> bool {
254+
self.test_before_acquire
255+
}
256+
227257
/// If set to `true`, calls to `acquire()` are fair and connections are issued
228258
/// in first-come-first-serve order. If `false`, "drive-by" tasks may steal idle connections
229259
/// ahead of tasks that have been waiting.

0 commit comments

Comments
 (0)