@@ -9,7 +9,7 @@ pub(crate) mod options;
9
9
mod status;
10
10
mod worker;
11
11
12
- use std:: { sync:: Arc , time :: Duration } ;
12
+ use std:: sync:: Arc ;
13
13
14
14
use derivative:: Derivative ;
15
15
@@ -21,7 +21,7 @@ pub(crate) use self::{
21
21
} ;
22
22
use self :: { connection_requester:: ConnectionRequestResult , options:: ConnectionPoolOptions } ;
23
23
use crate :: {
24
- error:: { Error , ErrorKind , Result } ,
24
+ error:: { Error , Result } ,
25
25
event:: cmap:: {
26
26
CmapEventHandler ,
27
27
ConnectionCheckoutFailedEvent ,
@@ -52,8 +52,6 @@ pub(crate) struct ConnectionPool {
52
52
connection_requester : ConnectionRequester ,
53
53
generation_subscriber : PoolGenerationSubscriber ,
54
54
55
- wait_queue_timeout : Option < Duration > ,
56
-
57
55
#[ derivative( Debug = "ignore" ) ]
58
56
event_handler : Option < Arc < dyn CmapEventHandler > > ,
59
57
}
@@ -73,7 +71,6 @@ impl ConnectionPool {
73
71
) ;
74
72
75
73
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 ) ;
77
74
78
75
if let Some ( ref handler) = event_handler {
79
76
handler. handle_pool_created_event ( PoolCreatedEvent {
@@ -87,7 +84,6 @@ impl ConnectionPool {
87
84
manager,
88
85
connection_requester,
89
86
generation_subscriber,
90
- wait_queue_timeout,
91
87
event_handler,
92
88
}
93
89
}
@@ -104,7 +100,6 @@ impl ConnectionPool {
104
100
manager,
105
101
connection_requester,
106
102
generation_subscriber,
107
- wait_queue_timeout : None ,
108
103
event_handler : None ,
109
104
}
110
105
}
@@ -120,9 +115,7 @@ impl ConnectionPool {
120
115
121
116
/// Checks out a connection from the pool. This method will yield until this thread is at the
122
117
/// 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.
126
119
pub ( crate ) async fn check_out ( & self ) -> Result < Connection > {
127
120
self . emit_event ( |handler| {
128
121
let event = ConnectionCheckoutStartedEvent {
@@ -132,21 +125,12 @@ impl ConnectionPool {
132
125
handler. handle_connection_checkout_started_event ( event) ;
133
126
} ) ;
134
127
135
- let response = self
136
- . connection_requester
137
- . request ( self . wait_queue_timeout )
138
- . await ;
128
+ let response = self . connection_requester . request ( ) . await ;
139
129
140
130
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 ) ) ,
150
134
} ;
151
135
152
136
match conn {
@@ -155,17 +139,11 @@ impl ConnectionPool {
155
139
handler. handle_connection_checked_out_event ( conn. checked_out_event ( ) ) ;
156
140
} ) ;
157
141
}
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 ( _) => {
165
143
self . emit_event ( |handler| {
166
144
handler. handle_connection_checkout_failed_event ( ConnectionCheckoutFailedEvent {
167
145
address : self . address . clone ( ) ,
168
- reason : failure_reason ,
146
+ reason : ConnectionCheckoutFailedReason :: ConnectionError ,
169
147
} )
170
148
} ) ;
171
149
}
0 commit comments