@@ -169,7 +169,9 @@ where
169
169
debug ! ( logger, "not found on polling" ; "object_id" => id. to_string( ) ) ;
170
170
171
171
metrics. not_found . inc ( ) ;
172
- queue. push_back ( id) ;
172
+
173
+ // We'll try again after a backoff.
174
+ backoff ( id, & queue, & mut backoffs) ;
173
175
}
174
176
175
177
// Error polling, log it and push the id to the back of the queue.
@@ -182,12 +184,7 @@ where
182
184
// Requests that return errors could mean there is a permanent issue with
183
185
// fetching the given item, or could signal the endpoint is overloaded.
184
186
// Either way a backoff makes sense.
185
- let queue = queue. cheap_clone ( ) ;
186
- let backoff = backoffs. next_backoff ( id. clone ( ) ) ;
187
- graph:: spawn ( async move {
188
- backoff. await ;
189
- queue. push_back ( id) ;
190
- } ) ;
187
+ backoff ( id, & queue, & mut backoffs) ;
191
188
}
192
189
}
193
190
}
@@ -197,6 +194,18 @@ where
197
194
PollingMonitor { queue }
198
195
}
199
196
197
+ fn backoff < ID > ( id : ID , queue : & Arc < Queue < ID > > , backoffs : & mut Backoffs < ID > )
198
+ where
199
+ ID : Eq + Hash + Clone + Send + ' static ,
200
+ {
201
+ let queue = queue. cheap_clone ( ) ;
202
+ let backoff = backoffs. next_backoff ( id. clone ( ) ) ;
203
+ graph:: spawn ( async move {
204
+ backoff. await ;
205
+ queue. push_back ( id) ;
206
+ } ) ;
207
+ }
208
+
200
209
/// Handle for adding objects to be monitored.
201
210
pub struct PollingMonitor < ID > {
202
211
queue : Arc < Queue < ID > > ,
0 commit comments