Skip to content

Commit

Permalink
retry on any transport error with a source
Browse files Browse the repository at this point in the history
  • Loading branch information
JssDWt committed Dec 2, 2024
1 parent a1dad04 commit ec42478
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions libs/sdk-common/src/tonic_wrap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ macro_rules! with_connection_retry {
($f:expr) => {{
use log::debug;
use std::error::Error;
const BROKEN_CONNECTION_STRINGS: [&str; 4] = [
"http2 error: keep-alive timed out",
"connection error: address not available",
"connection error: timed out",
"connection error: unexpected end of file",
];

async {
let res = $f.await;
Expand Down Expand Up @@ -73,18 +67,13 @@ macro_rules! with_connection_retry {
None => return Err(status),
};

// It's a bit of a guess which errors can occur here. hyper Io errors start
// with 'connection error'. These are some of the errors seen before.
if !BROKEN_CONNECTION_STRINGS.contains(&source.to_string().as_str()) {
debug!("transport error string is: '{}'", source.to_string());
return Err(status);
}

debug!(
"with_connection_fallback: initial call failed due to broken connection. Retrying fallback."
"with_connection_fallback: got transport error with source '{}'.
Retrying fallback.",
source.to_string()
);

$f.await
}
}};
}};
}

0 comments on commit ec42478

Please sign in to comment.