@@ -60,6 +60,11 @@ impl<M: ManageConnection> Pool<M> {
6060 pub fn state ( & self ) -> State {
6161 self . inner . state ( )
6262 }
63+
64+ /// Expose a representation of the original pool configuration
65+ pub fn config ( & self ) -> Config {
66+ Config :: from ( self . inner . builder ( ) )
67+ }
6368}
6469
6570impl < M : ManageConnection > Clone for Pool < M > {
@@ -132,6 +137,59 @@ impl Statistics {
132137 }
133138}
134139
140+ #[ non_exhaustive]
141+ #[ derive( Debug ) ]
142+ pub struct Config {
143+ /// The maximum number of connections allowed.
144+ pub max_size : u32 ,
145+ /// The minimum idle connection count the pool will attempt to maintain.
146+ pub min_idle : Option < u32 > ,
147+ /// Whether or not to test the connection on checkout.
148+ pub test_on_check_out : bool ,
149+ /// The maximum lifetime, if any, that a connection is allowed.
150+ pub max_lifetime : Option < Duration > ,
151+ /// The duration, if any, after which idle_connections in excess of `min_idle` are closed.
152+ pub idle_timeout : Option < Duration > ,
153+ /// The duration to wait to start a connection before giving up.
154+ pub connection_timeout : Duration ,
155+ /// Enable/disable automatic retries on connection creation.
156+ pub retry_connection : bool ,
157+ /// The time interval used to wake up and reap connections.
158+ pub reaper_rate : Duration ,
159+ /// Queue strategy (FIFO or LIFO)
160+ pub queue_strategy : QueueStrategy ,
161+ }
162+
163+ impl < M : ManageConnection > From < & Builder < M > > for Config {
164+ fn from ( builder : & Builder < M > ) -> Self {
165+ let Builder {
166+ max_size,
167+ min_idle,
168+ test_on_check_out,
169+ max_lifetime,
170+ idle_timeout,
171+ connection_timeout,
172+ retry_connection,
173+ error_sink : _,
174+ reaper_rate,
175+ queue_strategy,
176+ connection_customizer : _,
177+ _p : _,
178+ } = builder;
179+
180+ Self {
181+ max_size : * max_size,
182+ min_idle : * min_idle,
183+ test_on_check_out : * test_on_check_out,
184+ max_lifetime : * max_lifetime,
185+ idle_timeout : * idle_timeout,
186+ connection_timeout : * connection_timeout,
187+ retry_connection : * retry_connection,
188+ reaper_rate : * reaper_rate,
189+ queue_strategy : * queue_strategy,
190+ }
191+ }
192+ }
135193/// A builder for a connection pool.
136194#[ derive( Debug ) ]
137195pub struct Builder < M : ManageConnection > {
0 commit comments