@@ -3,17 +3,15 @@ use crate::db::{delete_crate, Pool};
33use crate :: docbuilder:: PackageKind ;
44use crate :: error:: Result ;
55use crate :: storage:: Storage ;
6- use crate :: utils:: { get_config, get_crate_priority, report_error, set_config, ConfigName } ;
6+ use crate :: utils:: { get_config, get_crate_priority, report_error, retry , set_config, ConfigName } ;
77use crate :: { Config , Index , Metrics , RustwideBuilder } ;
88use anyhow:: Context ;
99use fn_error_context:: context;
1010
11- use tracing:: { debug, error, info, warn } ;
11+ use tracing:: { debug, error, info} ;
1212
1313use std:: collections:: HashMap ;
1414use std:: sync:: Arc ;
15- use std:: thread;
16- use std:: time:: Duration ;
1715
1816#[ derive( Debug , Clone , Eq , PartialEq , serde:: Serialize ) ]
1917pub ( crate ) struct QueuedCrate {
@@ -262,27 +260,6 @@ impl BuildQueue {
262260 }
263261}
264262
265- fn retry < T > ( mut f : impl FnMut ( ) -> Result < T > , max_attempts : u32 ) -> Result < T > {
266- for attempt in 1 .. {
267- match f ( ) {
268- Ok ( result) => return Ok ( result) ,
269- Err ( err) => {
270- if attempt > max_attempts {
271- return Err ( err) ;
272- } else {
273- let sleep_for = 2u32 . pow ( attempt) ;
274- warn ! (
275- "got error on attempt {}, will try again after {}s:\n {:?}" ,
276- attempt, sleep_for, err
277- ) ;
278- thread:: sleep ( Duration :: from_secs ( sleep_for as u64 ) ) ;
279- }
280- }
281- }
282- }
283- unreachable ! ( )
284- }
285-
286263/// Index methods.
287264impl BuildQueue {
288265 /// Updates registry index repository and adds new crates into build queue.
0 commit comments