/// Load data from graphite
///
/// Retry until success or exit the script
Load data from graphite
Retry until success or exit the script
Load data from graphite Retry until success or exit the script
pub fn fetch_data(
    url: &str,
    target: &str,
    window: i64,
    start_at: i64,
    retries: u8,
    graphite_error: &Status,
    print_url: bool,
) -> Result<GraphiteResponse, String> {
    let mut attempts = 0;
    let mut retry_sleep = 2000;
    loop {
        match get_graphite(url, target, window, start_at, print_url, graphite_error) {
            Ok(s) => {
                return Ok(s);
            }
            Err(e) => {
                print!("Error for {}: {}. ", url, e.short_display());
                if attempts < retries {
                    println!("Retrying in {}s.", retry_sleep / 1000);
                    attempts += 1;
                    sleep(Duration::from_millis(retry_sleep));
                    retry_sleep *= 2;
                    continue;
                } else {
                    println!("\nFull error: {}", e);
                    println!("Giving up after {} attempts.", retries + 1);
                    graphite_error.exit();
                }
            }
        }
    }
}
pub fn fetch_data ( url : & str , target : & str , window : i64 , start_at : i64 , retries : u8 , graphite_error : & Status , print_url : bool , ) -> Result < GraphiteResponse , String > { let mut attempts = 0 ; let mut retry_sleep = 2000 ; loop { match get_graphite ( url , target , window , start_at , print_url , graphite_error ) { Ok ( s ) => { return Ok ( s ) ; } Err ( e ) => { print ! ( " " url e short_display ( ) ) ; if attempts < retries { println ! ( " " retry_sleep 1000 ) ; attempts += 1 ; sleep ( Duration :: from_millis ( retry_sleep ) ) ; retry_sleep *= 2 ; continue ; } else { println ! ( " \n " e ) ; println ! ( " " retries 1 ) ; graphite_error . exit ( ) ; } } } } }
Load data from graphite
Retry until success or exit the script
Load data from graphite Retry until success or exit the script
url
&str
target
&str
window
i64
start_at
i64
retries
u8
graphite_error
&Status
print_url
bool