Skip to content

Commit

Permalink
Merge pull request #549 from hodgesds/stats-path-fix
Browse files Browse the repository at this point in the history
scx_utils: Add retryable errors
  • Loading branch information
hodgesds authored Aug 25, 2024
2 parents a469f0f + c31f2b6 commit bf67b83
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rust/scx_utils/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ where
T: for<'a> Deserialize<'a>,
{
let mut retry_cnt: u32 = 0;

const RETRYABLE_ERRORS: [std::io::ErrorKind; 2] = [
std::io::ErrorKind::NotFound,
std::io::ErrorKind::ConnectionRefused,
];

while !should_exit() {
let mut client = match StatsClient::new().connect() {
Ok(v) => v,
Err(e) => match e.downcast_ref::<std::io::Error>() {
Some(ioe) if ioe.kind() == std::io::ErrorKind::ConnectionRefused => {
Some(ioe) if RETRYABLE_ERRORS.contains(&ioe.kind()) => {
if retry_cnt == 1 {
info!("Stats server not avaliable, retrying...");
}
Expand Down

0 comments on commit bf67b83

Please sign in to comment.