@@ -4,20 +4,20 @@ use pixi_consts::consts;
4
4
use rattler_networking:: {
5
5
authentication_storage:: { self , backends:: file:: FileStorageError } ,
6
6
mirror_middleware:: Mirror ,
7
- retry_policies:: ExponentialBackoff ,
8
7
AuthenticationMiddleware , AuthenticationStorage , GCSMiddleware , MirrorMiddleware ,
9
8
OciMiddleware ,
10
9
} ;
10
+ use reqwest_retry:: RetryTransientMiddleware ;
11
+ use retry_policies:: policies:: ExponentialBackoff ;
12
+ use retry_policies:: Jitter ;
11
13
12
14
use reqwest:: Client ;
13
15
use reqwest_middleware:: { ClientBuilder , ClientWithMiddleware } ;
14
16
use std:: collections:: HashMap ;
15
17
16
18
use pixi_config:: Config ;
17
19
18
- /// The default retry policy employed by pixi.
19
- /// TODO: At some point we might want to make this configurable.
20
- pub fn default_retry_policy ( ) -> ExponentialBackoff {
20
+ fn default_retry_policy ( ) -> ExponentialBackoff {
21
21
ExponentialBackoff :: builder ( ) . build_with_max_retries ( 3 )
22
22
}
23
23
@@ -101,9 +101,17 @@ pub fn build_reqwest_clients(config: Option<&Config>) -> (Client, ClientWithMidd
101
101
. expect ( "failed to create reqwest Client" ) ;
102
102
103
103
let mut client_builder = ClientBuilder :: new ( client. clone ( ) ) ;
104
+ let retry_policy = ExponentialBackoff :: builder ( )
105
+ . retry_bounds ( Duration :: from_secs ( 1 ) , Duration :: from_secs ( 60 ) )
106
+ . jitter ( Jitter :: Bounded )
107
+ . base ( 2 )
108
+ . build_with_total_retry_duration ( Duration :: from_secs ( 24 * 60 * 60 ) ) ;
109
+
110
+ let retry_transient_middleware = RetryTransientMiddleware :: new_with_policy ( retry_policy) ;
104
111
105
112
if !config. mirror_map ( ) . is_empty ( ) {
106
113
client_builder = client_builder
114
+ . with ( retry_transient_middleware)
107
115
. with ( mirror_middleware ( & config) )
108
116
. with ( oci_middleware ( ) ) ;
109
117
}
0 commit comments