@@ -74,6 +74,14 @@ impl<M: ManageConnection> Pool<M> {
74
74
}
75
75
}
76
76
77
+ #[ derive( Debug ) ]
78
+ pub enum QueueStrategy {
79
+ /// Last in first out
80
+ LIFO ,
81
+ /// First in first out
82
+ FIFO ,
83
+ }
84
+
77
85
/// A builder for a connection pool.
78
86
#[ derive( Debug ) ]
79
87
pub struct Builder < M : ManageConnection > {
@@ -95,6 +103,8 @@ pub struct Builder<M: ManageConnection> {
95
103
pub ( crate ) error_sink : Box < dyn ErrorSink < M :: Error > > ,
96
104
/// The time interval used to wake up and reap connections.
97
105
pub ( crate ) reaper_rate : Duration ,
106
+ /// Queue strategy (FIFO or LIFO)
107
+ pub ( crate ) queue_strategy : QueueStrategy ,
98
108
/// User-supplied trait object responsible for initializing connections
99
109
pub ( crate ) connection_customizer : Option < Box < dyn CustomizeConnection < M :: Connection , M :: Error > > > ,
100
110
_p : PhantomData < M > ,
@@ -112,6 +122,7 @@ impl<M: ManageConnection> Default for Builder<M> {
112
122
retry_connection : true ,
113
123
error_sink : Box :: new ( NopErrorSink ) ,
114
124
reaper_rate : Duration :: from_secs ( 30 ) ,
125
+ queue_strategy : QueueStrategy :: FIFO ,
115
126
connection_customizer : None ,
116
127
_p : PhantomData ,
117
128
}
@@ -260,6 +271,15 @@ impl<M: ManageConnection> Builder<M> {
260
271
self
261
272
}
262
273
274
+ /// Sets the queue strategy to be used by the pool
275
+ ///
276
+ /// Defaults to `FIFO`.
277
+ #[ must_use]
278
+ pub fn queue_strategy ( mut self , queue_strategy : QueueStrategy ) -> Self {
279
+ self . queue_strategy = queue_strategy;
280
+ self
281
+ }
282
+
263
283
/// Set the connection customizer to customize newly checked out connections
264
284
#[ must_use]
265
285
pub fn connection_customizer (
0 commit comments