Skip to content

Commit

Permalink
refactor(blockifier_reexecution): refactor retry config params
Browse files Browse the repository at this point in the history
  • Loading branch information
AvivYossef-starkware committed Nov 10, 2024
1 parent ded309d commit 4d9ae84
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/blockifier_reexecution/src/state_reader/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,29 @@ impl TryFrom<ReexecutionStateMaps> for StateMaps {
#[macro_export]
macro_rules! retry_request {
($retry_config:expr, $closure:expr) => {{
let mut attempt_number = 0;
retry::retry(
retry::delay::Fixed::from_millis($retry_config.retry_interval_milliseconds)
.take($retry_config.n_retries),
|| {
attempt_number += 1;
match $closure() {
Ok(value) => retry::OperationResult::Ok(value),
// If the error contains the expected_error_string , we want to retry.
// If the error contains any of the expected error strings, we want to retry.
Err(e)
if $retry_config
.expected_error_strings
.iter()
.any(|s| e.to_string().contains(s)) =>
{
println!(
"Attempt {}: Retrying request due to error: {:?}",
attempt_number, e
);
println!(
"Retry delay in milliseconds: {}",
$retry_config.retry_interval_milliseconds
);
retry::OperationResult::Retry(e)
}
// For all other errors, do not retry and return immediately.
Expand Down

0 comments on commit 4d9ae84

Please sign in to comment.