Watch
0
0
Fork
You've already forked hyperhive
0

retry the remaining plain schedules with backon

This commit is contained in:
damocles 2026-10-17 15:25:22 +02:00 • committed by mara
commit ed76419be7

View file

@ -29,6 +29,7 @@
use std::{future::Future, time::Duration};
use anyhow::{Context, Result};
use backon::{BackoffBuilder as _, ConstantBuilder};
use swarm_secret_client::{Error, SecretStore, client::DEFAULT_CERT_MOUNT, policy};
/// File holding the authority hives are issued from, as
@ -111,12 +112,14 @@ where
F: FnMut() -> Fut,
Fut: Future<Output = Result<(), Unreachable>>,
{
let mut ticker = tokio::time::interval(interval);
// `interval`'s first tick is immediate, and that pass is the one the caller
// already ran before deciding to retry at all.
ticker.tick().await;
for n in 1..=attempts {
ticker.tick().await;
// One delay per attempt, waited before it: the pass the caller already ran
// before deciding to retry at all is the attempt that needs no wait.
let delays = ConstantBuilder::default()
.with_delay(interval)
.with_max_times(attempts as usize)
.build();
for (n, delay) in (1..).zip(delays) {
tokio::time::sleep(delay).await;
if attempt().await.is_ok() {
return Some(n);
}