From: Jérôme Benoit Date: Tue, 11 Apr 2023 19:16:28 +0000 (+0200) Subject: refactor: make the exponential backoff implementation for tunable X-Git-Tag: v1.2.6~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=517ffa58b673e8ece31c6520d0f2331848fc05ed;p=e-mobility-charging-stations-simulator.git refactor: make the exponential backoff implementation for tunable Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 058d175d..4306d887 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -249,9 +249,9 @@ export class Utils { * @param retryNumber - the number of retries that have already been attempted * @returns delay in milliseconds */ - public static exponentialDelay(retryNumber = 0): number { + public static exponentialDelay(retryNumber = 0, maxDelayRatio = 0.2): number { const delay = Math.pow(2, retryNumber) * 100; - const randomSum = delay * 0.2 * Utils.secureRandom(); // 0-20% of the delay + const randomSum = delay * maxDelayRatio * Utils.secureRandom(); // 0-20% of the delay return delay + randomSum; }