@@ -169,7 +169,9 @@ where
169169 debug ! ( logger, "not found on polling" ; "object_id" => id. to_string( ) ) ;
170170
171171 metrics. not_found . inc ( ) ;
172- queue. push_back ( id) ;
172+
173+ // We'll try again after a backoff.
174+ backoff ( id, & queue, & mut backoffs) ;
173175 }
174176
175177 // Error polling, log it and push the id to the back of the queue.
@@ -182,12 +184,7 @@ where
182184 // Requests that return errors could mean there is a permanent issue with
183185 // fetching the given item, or could signal the endpoint is overloaded.
184186 // 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) ;
191188 }
192189 }
193190 }
@@ -197,6 +194,18 @@ where
197194 PollingMonitor { queue }
198195}
199196
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+
200209/// Handle for adding objects to be monitored.
201210pub struct PollingMonitor < ID > {
202211 queue : Arc < Queue < ID > > ,
0 commit comments