@@ -77,6 +77,7 @@ pub struct PoolOptions<DB: Database> {
77
77
pub ( crate ) max_connections : u32 ,
78
78
pub ( crate ) acquire_time_level : LevelFilter ,
79
79
pub ( crate ) acquire_slow_level : LevelFilter ,
80
+ pub ( crate ) return_con_refused : bool ,
80
81
pub ( crate ) acquire_slow_threshold : Duration ,
81
82
pub ( crate ) acquire_timeout : Duration ,
82
83
pub ( crate ) min_connections : u32 ,
@@ -101,6 +102,7 @@ impl<DB: Database> Clone for PoolOptions<DB> {
101
102
acquire_time_level : self . acquire_time_level ,
102
103
acquire_slow_threshold : self . acquire_slow_threshold ,
103
104
acquire_slow_level : self . acquire_slow_level ,
105
+ return_con_refused : self . return_con_refused ,
104
106
acquire_timeout : self . acquire_timeout ,
105
107
min_connections : self . min_connections ,
106
108
max_lifetime : self . max_lifetime ,
@@ -154,6 +156,7 @@ impl<DB: Database> PoolOptions<DB> {
154
156
acquire_time_level : LevelFilter :: Off ,
155
157
// Default to warning, because an acquire timeout will be an error
156
158
acquire_slow_level : LevelFilter :: Warn ,
159
+ return_con_refused : false ,
157
160
// Fast enough to catch problems (e.g. a full pool); slow enough
158
161
// to not flag typical time to add a new connection to a pool.
159
162
acquire_slow_threshold : Duration :: from_secs ( 2 ) ,
@@ -229,6 +232,13 @@ impl<DB: Database> PoolOptions<DB> {
229
232
self
230
233
}
231
234
235
+ /// immediately return connection refused errors instead of hanging
236
+ /// until returning PoolTimedOut
237
+ pub fn return_con_refused ( mut self , value : bool ) -> Self {
238
+ self . return_con_refused = value;
239
+ self
240
+ }
241
+
232
242
/// Set a threshold for reporting excessive time taken to acquire a connection from
233
243
/// the connection pool via [`Pool::acquire()`]. When the threshold is exceeded, a warning is logged.
234
244
///
0 commit comments