X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FUtils.ts;h=48d0587cbce16e9db798c48877795325e8088eff;hb=ec4a242aa5f1a9d4201d0ec9988f9dd931978589;hp=54b0751022130ba18e3a238cc58a78d741acb39e;hpb=991fb26bd3814b583395f5d2623acfae7a3ee3f0;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 54b07510..48d0587c 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -262,11 +262,12 @@ export const insertAt = (str: string, subStr: string, pos: number): string => * Computes the retry delay in milliseconds using an exponential backoff algorithm. * * @param retryNumber - the number of retries that have already been attempted + * @param maxDelayRatio - the maximum ratio of the delay that can be randomized * @returns delay in milliseconds */ export const exponentialDelay = (retryNumber = 0, maxDelayRatio = 0.2): number => { const delay = Math.pow(2, retryNumber) * 100; - const randomSum = delay * maxDelayRatio * secureRandom(); // 0-20% of the delay + const randomSum = delay * maxDelayRatio * secureRandom(); // 0-(maxDelayRatio*100)% of the delay return delay + randomSum; };