mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 05:27:52 +00:00
switched to applyJitter functions
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import RE2 from "re2";
|
import RE2 from "re2";
|
||||||
|
|
||||||
import { TKeyStoreFactory } from "@app/keystore/keystore";
|
import { TKeyStoreFactory } from "@app/keystore/keystore";
|
||||||
|
import { applyJitter } from "@app/lib/dates";
|
||||||
import { delay as delayMs } from "@app/lib/delay";
|
import { delay as delayMs } from "@app/lib/delay";
|
||||||
import { Lock } from "@app/lib/red-lock";
|
import { Lock } from "@app/lib/red-lock";
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ export const mockKeyStore = (): TKeyStoreFactory => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await delayMs(Math.max(0, delay + Math.floor((Math.random() * 2 - 1) * jitter)));
|
await delayMs(Math.max(0, applyJitter(delay, jitter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalDeleted;
|
return totalDeleted;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Redis } from "ioredis";
|
import { Redis } from "ioredis";
|
||||||
|
|
||||||
import { pgAdvisoryLockHashText } from "@app/lib/crypto/hashtext";
|
import { pgAdvisoryLockHashText } from "@app/lib/crypto/hashtext";
|
||||||
|
import { applyJitter } from "@app/lib/dates";
|
||||||
import { delay as delayMs } from "@app/lib/delay";
|
import { delay as delayMs } from "@app/lib/delay";
|
||||||
import { Redlock, Settings } from "@app/lib/red-lock";
|
import { Redlock, Settings } from "@app/lib/red-lock";
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ export const keyStoreFactory = (redisUrl: string) => {
|
|||||||
totalDeleted += batch.length;
|
totalDeleted += batch.length;
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await delayMs(Math.max(0, delay + Math.floor((Math.random() * 2 - 1) * jitter)));
|
await delayMs(Math.max(0, applyJitter(delay, jitter)));
|
||||||
}
|
}
|
||||||
} while (cursor !== "0");
|
} while (cursor !== "0");
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ export const keyStoreFactory = (redisUrl: string) => {
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
waitingCb?.();
|
waitingCb?.();
|
||||||
setTimeout(resolve, Math.max(0, delay + Math.floor((Math.random() * 2 - 1) * jitter)));
|
setTimeout(resolve, Math.max(0, applyJitter(delay, jitter)));
|
||||||
});
|
});
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import RE2 from "re2";
|
import RE2 from "re2";
|
||||||
|
|
||||||
|
import { applyJitter } from "@app/lib/dates";
|
||||||
import { delay as delayMs } from "@app/lib/delay";
|
import { delay as delayMs } from "@app/lib/delay";
|
||||||
import { Lock } from "@app/lib/red-lock";
|
import { Lock } from "@app/lib/red-lock";
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ export const inMemoryKeyStore = (): TKeyStoreFactory => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await delayMs(Math.max(0, delay + Math.floor((Math.random() * 2 - 1) * jitter)));
|
await delayMs(Math.max(0, applyJitter(delay, jitter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalDeleted;
|
return totalDeleted;
|
||||||
|
|||||||
Reference in New Issue
Block a user