From 5d670513d6ea18afc092967a2c2806df9eafd6fe Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 21 Nov 2022 14:38:39 +0000 Subject: [PATCH] Only retry activity sending at most 3 times (#7) --- src/core/activity_queue.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/core/activity_queue.rs b/src/core/activity_queue.rs index 8f7ec03..dc4c5df 100644 --- a/src/core/activity_queue.rs +++ b/src/core/activity_queue.rs @@ -110,19 +110,15 @@ impl ActixJob for SendActivityTask { type Future = Pin>>>; const NAME: &'static str = "SendActivityTask"; - /// With these params, retries are made at the following intervals: - /// 3s - /// 9s - /// 27s - /// 1m 21s - /// 4m 3s - /// 12m 9s - /// 36m 27s - /// 1h 49m 21s - /// 5h 28m 3s - /// 16h 24m 9s - const MAX_RETRIES: MaxRetries = MaxRetries::Count(10); - const BACKOFF: Backoff = Backoff::Exponential(3); + /// We need to retry activity sending in case the target instances is temporarily unreachable. + /// In this case, the task is stored and resent when the instance is hopefully back up. This + /// list shows the retry intervals, and which events of the target instance can be covered: + /// - 60s (one minute, service restart) + /// - 60min (one hour, instance maintenance) + /// - 60h (2.5 days, major incident with rebuild from backup) + /// TODO: make the intervals configurable + const MAX_RETRIES: MaxRetries = MaxRetries::Count(3); + const BACKOFF: Backoff = Backoff::Exponential(60); fn run(self, state: Self::State) -> Self::Future { Box::pin(async move { do_send(self, &state.client, state.timeout).await })