@@ -125,7 +125,7 @@ pub(crate) struct RequestService<T: ConnectionModeProvider> {
125
125
connector_handle : HttpsConnectorWithSniHandle ,
126
126
client : hyper:: Client < HttpsConnectorWithSni , hyper:: Body > ,
127
127
connection_mode_provider : T ,
128
- connection_mode_generation : usize ,
128
+ allow_new_mode : bool ,
129
129
api_availability : ApiAvailabilityHandle ,
130
130
}
131
131
@@ -158,7 +158,7 @@ impl<T: ConnectionModeProvider + 'static> RequestService<T> {
158
158
connector_handle,
159
159
client,
160
160
connection_mode_provider,
161
- connection_mode_generation : 0 ,
161
+ allow_new_mode : true ,
162
162
api_availability,
163
163
} ;
164
164
let handle = RequestServiceHandle { tx : command_tx } ;
@@ -190,15 +190,15 @@ impl<T: ConnectionModeProvider + 'static> RequestService<T> {
190
190
async fn process_command ( & mut self , command : RequestCommand ) {
191
191
match command {
192
192
RequestCommand :: NewRequest ( request, completion_tx) => {
193
+ self . allow_new_mode = true ;
193
194
self . handle_new_request ( request, completion_tx) ;
194
195
}
195
196
RequestCommand :: Reset => {
196
197
self . connector_handle . reset ( ) ;
197
198
}
198
- RequestCommand :: NextApiConfig ( generation) => {
199
- if generation == self . connection_mode_generation {
200
- self . connection_mode_generation =
201
- self . connection_mode_generation . wrapping_add ( 1 ) ;
199
+ RequestCommand :: NextApiConfig => {
200
+ if self . allow_new_mode {
201
+ self . allow_new_mode = false ;
202
202
self . connection_mode_provider . rotate ( ) . await ;
203
203
}
204
204
}
@@ -215,8 +215,6 @@ impl<T: ConnectionModeProvider + 'static> RequestService<T> {
215
215
let api_availability = self . api_availability . clone ( ) ;
216
216
let request_future = request. into_future ( self . client . clone ( ) , api_availability. clone ( ) ) ;
217
217
218
- let connection_mode_generation = self . connection_mode_generation ;
219
-
220
218
tokio:: spawn ( async move {
221
219
let response = request_future. await . map_err ( |error| error. map_aborted ( ) ) ;
222
220
@@ -225,9 +223,7 @@ impl<T: ConnectionModeProvider + 'static> RequestService<T> {
225
223
if err. is_network_error ( ) && !api_availability. get_state ( ) . is_offline ( ) {
226
224
log:: error!( "{}" , err. display_chain_with_msg( "HTTP request failed" ) ) ;
227
225
if let Some ( tx) = tx {
228
- let _ = tx. unbounded_send ( RequestCommand :: NextApiConfig (
229
- connection_mode_generation,
230
- ) ) ;
226
+ let _ = tx. unbounded_send ( RequestCommand :: NextApiConfig ) ;
231
227
}
232
228
}
233
229
}
@@ -266,7 +262,7 @@ pub(crate) enum RequestCommand {
266
262
oneshot:: Sender < std:: result:: Result < Response , Error > > ,
267
263
) ,
268
264
Reset ,
269
- NextApiConfig ( usize ) ,
265
+ NextApiConfig ,
270
266
}
271
267
272
268
/// A REST request that is sent to the RequestService to be executed.
0 commit comments