refactor: make the exponential backoff implementation for tunable
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 11 Apr 2023 19:16:28 +0000 (21:16 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 11 Apr 2023 19:16:28 +0000 (21:16 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/utils/Utils.ts

index 058d175d0d7ebc3c3776205c6c5c9429570a2358..4306d8872e0114928481769feb6bb6daf5ff603e 100644 (file)
@@ -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;
   }