Skip to content

Commit

Permalink
do several retries before bailing out
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed May 20, 2022
1 parent fab6278 commit 07e1444
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bin/inx-chronicle/src/metrics.rs
Expand Up @@ -89,14 +89,24 @@ impl Actor for MetricsWorker {

let process_metrics_handle = {
tokio::spawn(async move {
if let Err(e) = metrics.update().await {
log::warn!("Cannot update process metrics: {e}");
}
const MAX_RETRIES: u8 = 5;
let mut retries = MAX_RETRIES;

loop {
while retries > 0 {
sleep(Duration::from_secs(1)).await;
let _ = metrics.update().await;

match metrics.update().await {
Ok(_) => {
retries = MAX_RETRIES;
}
Err(e) => {
log::warn!("Cannot update process metrics: {e}");
retries -= 1;
}
}
}

log::warn!("Could not update process metrics after {MAX_RETRIES} retries");
})
};

Expand Down

0 comments on commit 07e1444

Please sign in to comment.