I have a function that try to call some services, one of them ( external service) have a lot of issues, and never give any answers and I would like to kill it after certain time.
I would like to find any crate that could set a timeout calling a function. But I can't manage to find one ?
fn main() {
let result = retry::retry(Fixed::from_millis(3000).take(5), || {
let possibly_return = function_maybe_never_return();
match possibly_return {
Ok(kubeconfig) => OperationResult::Ok(kubeconfig),
Err(err) => Err(err)
}
});
match result {
Ok(downloaded) => info!("OK !!")
Err(e) => Error!("Unable to ... after many retries {:?}", e),
};
}
fn function_maybe_never_return(){
}
I want to use retry crate on it to retrying operation.