@@ -53,6 +53,7 @@ pub struct Config {
53
53
cached_log_level : log:: LevelFilter ,
54
54
cached_vcs_remote : String ,
55
55
cached_token_data : Option < AuthTokenPayload > ,
56
+ max_retries : u32 ,
56
57
}
57
58
58
59
impl Config {
@@ -91,6 +92,7 @@ impl Config {
91
92
cached_headers : get_default_headers ( & ini) ,
92
93
cached_log_level : get_default_log_level ( & ini) ,
93
94
cached_vcs_remote : get_default_vcs_remote ( & ini) ,
95
+ max_retries : get_max_retries ( & ini) ,
94
96
ini,
95
97
cached_token_data : token_embedded_data,
96
98
}
@@ -468,27 +470,8 @@ impl Config {
468
470
}
469
471
470
472
/// Returns the configured maximum number of retries for failed HTTP requests.
471
- pub fn get_max_retry_count ( & self ) -> u32 {
472
- match max_retries_from_env ( ) {
473
- Ok ( Some ( val) ) => return val,
474
- Ok ( None ) => ( ) ,
475
- Err ( e) => {
476
- warn ! (
477
- "Ignoring invalid {MAX_RETRIES_ENV_VAR} environment variable: {}" ,
478
- e
479
- ) ;
480
- }
481
- } ;
482
-
483
- match max_retries_from_ini ( & self . ini ) {
484
- Ok ( Some ( val) ) => return val,
485
- Ok ( None ) => ( ) ,
486
- Err ( e) => {
487
- warn ! ( "Ignoring invalid {MAX_RETRIES_INI_KEY} ini key: {}" , e) ;
488
- }
489
- } ;
490
-
491
- DEFAULT_RETRIES
473
+ pub fn max_retries ( & self ) -> u32 {
474
+ self . max_retries
492
475
}
493
476
494
477
/// Return the DSN
@@ -539,6 +522,32 @@ impl Config {
539
522
}
540
523
}
541
524
525
+ /// Obtains the maximum number of retries from the environment or the ini file.
526
+ /// Environment variable takes precedence over the ini file. If neither is set,
527
+ /// the default value is returned.
528
+ fn get_max_retries ( ini : & Ini ) -> u32 {
529
+ match max_retries_from_env ( ) {
530
+ Ok ( Some ( val) ) => return val,
531
+ Ok ( None ) => ( ) ,
532
+ Err ( e) => {
533
+ warn ! (
534
+ "Ignoring invalid {MAX_RETRIES_ENV_VAR} environment variable: {}" ,
535
+ e
536
+ ) ;
537
+ }
538
+ } ;
539
+
540
+ match max_retries_from_ini ( ini) {
541
+ Ok ( Some ( val) ) => return val,
542
+ Ok ( None ) => ( ) ,
543
+ Err ( e) => {
544
+ warn ! ( "Ignoring invalid {MAX_RETRIES_INI_KEY} ini key: {}" , e) ;
545
+ }
546
+ } ;
547
+
548
+ DEFAULT_RETRIES
549
+ }
550
+
542
551
/// Computes the maximum number of retries from the `SENTRY_HTTP_MAX_RETRIES` environment variable.
543
552
/// Returns `Ok(None)` if the environment variable is not set, other errors are returned as is.
544
553
fn max_retries_from_env ( ) -> Result < Option < u32 > > {
@@ -709,6 +718,7 @@ impl Clone for Config {
709
718
cached_log_level : self . cached_log_level ,
710
719
cached_vcs_remote : self . cached_vcs_remote . clone ( ) ,
711
720
cached_token_data : self . cached_token_data . clone ( ) ,
721
+ max_retries : self . max_retries ,
712
722
}
713
723
}
714
724
}
@@ -794,6 +804,7 @@ mod tests {
794
804
cached_log_level : LevelFilter :: Off ,
795
805
cached_vcs_remote : String :: new ( ) ,
796
806
cached_token_data : None ,
807
+ max_retries : 0 ,
797
808
} ;
798
809
799
810
assert_eq ! (
0 commit comments