@@ -9,7 +9,7 @@ pub(crate) mod options;
99mod status;
1010mod worker;
1111
12- use std:: { sync:: Arc , time :: Duration } ;
12+ use std:: sync:: Arc ;
1313
1414use derivative:: Derivative ;
1515
@@ -21,7 +21,7 @@ pub(crate) use self::{
2121} ;
2222use self :: { connection_requester:: ConnectionRequestResult , options:: ConnectionPoolOptions } ;
2323use crate :: {
24- error:: { Error , ErrorKind , Result } ,
24+ error:: { Error , Result } ,
2525 event:: cmap:: {
2626 CmapEventHandler ,
2727 ConnectionCheckoutFailedEvent ,
@@ -52,8 +52,6 @@ pub(crate) struct ConnectionPool {
5252 connection_requester : ConnectionRequester ,
5353 generation_subscriber : PoolGenerationSubscriber ,
5454
55- wait_queue_timeout : Option < Duration > ,
56-
5755 #[ derivative( Debug = "ignore" ) ]
5856 event_handler : Option < Arc < dyn CmapEventHandler > > ,
5957}
@@ -73,7 +71,6 @@ impl ConnectionPool {
7371 ) ;
7472
7573 let event_handler = options. as_ref ( ) . and_then ( |opts| opts. event_handler . clone ( ) ) ;
76- let wait_queue_timeout = options. as_ref ( ) . and_then ( |opts| opts. wait_queue_timeout ) ;
7774
7875 if let Some ( ref handler) = event_handler {
7976 handler. handle_pool_created_event ( PoolCreatedEvent {
@@ -87,7 +84,6 @@ impl ConnectionPool {
8784 manager,
8885 connection_requester,
8986 generation_subscriber,
90- wait_queue_timeout,
9187 event_handler,
9288 }
9389 }
@@ -104,7 +100,6 @@ impl ConnectionPool {
104100 manager,
105101 connection_requester,
106102 generation_subscriber,
107- wait_queue_timeout : None ,
108103 event_handler : None ,
109104 }
110105 }
@@ -120,9 +115,7 @@ impl ConnectionPool {
120115
121116 /// Checks out a connection from the pool. This method will yield until this thread is at the
122117 /// front of the wait queue, and then will block again if no available connections are in the
123- /// pool and the total number of connections is not less than the max pool size. If the method
124- /// blocks for longer than `wait_queue_timeout` waiting for an available connection or to
125- /// start establishing a new one, a `WaitQueueTimeoutError` will be returned.
118+ /// pool and the total number of connections is not less than the max pool size.
126119 pub ( crate ) async fn check_out ( & self ) -> Result < Connection > {
127120 self . emit_event ( |handler| {
128121 let event = ConnectionCheckoutStartedEvent {
@@ -132,21 +125,12 @@ impl ConnectionPool {
132125 handler. handle_connection_checkout_started_event ( event) ;
133126 } ) ;
134127
135- let response = self
136- . connection_requester
137- . request ( self . wait_queue_timeout )
138- . await ;
128+ let response = self . connection_requester . request ( ) . await ;
139129
140130 let conn = match response {
141- Some ( ConnectionRequestResult :: Pooled ( c) ) => Ok ( c) ,
142- Some ( ConnectionRequestResult :: Establishing ( task) ) => task. await ,
143- Some ( ConnectionRequestResult :: PoolCleared ) => {
144- Err ( Error :: pool_cleared_error ( & self . address ) )
145- }
146- None => Err ( ErrorKind :: WaitQueueTimeout {
147- address : self . address . clone ( ) ,
148- }
149- . into ( ) ) ,
131+ ConnectionRequestResult :: Pooled ( c) => Ok ( c) ,
132+ ConnectionRequestResult :: Establishing ( task) => task. await ,
133+ ConnectionRequestResult :: PoolCleared => Err ( Error :: pool_cleared_error ( & self . address ) ) ,
150134 } ;
151135
152136 match conn {
@@ -155,17 +139,11 @@ impl ConnectionPool {
155139 handler. handle_connection_checked_out_event ( conn. checked_out_event ( ) ) ;
156140 } ) ;
157141 }
158- Err ( ref e) => {
159- let failure_reason = if let ErrorKind :: WaitQueueTimeout { .. } = * e. kind {
160- ConnectionCheckoutFailedReason :: Timeout
161- } else {
162- ConnectionCheckoutFailedReason :: ConnectionError
163- } ;
164-
142+ Err ( _) => {
165143 self . emit_event ( |handler| {
166144 handler. handle_connection_checkout_failed_event ( ConnectionCheckoutFailedEvent {
167145 address : self . address . clone ( ) ,
168- reason : failure_reason ,
146+ reason : ConnectionCheckoutFailedReason :: ConnectionError ,
169147 } )
170148 } ) ;
171149 }
0 commit comments