1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

feat(kv_queues): increase max queue delay to 30 days (#20626)

This commit is contained in:
Igor Zinkovsky 2023-09-22 09:40:35 -07:00 committed by GitHub
parent 15cfb67551
commit 035df85732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -1550,9 +1550,9 @@ dbTest("queue nan delay", async (db) => {
}); });
dbTest("queue large delay", async (db) => { dbTest("queue large delay", async (db) => {
await db.enqueue("test", { delay: 7 * 24 * 60 * 60 * 1000 }); await db.enqueue("test", { delay: 30 * 24 * 60 * 60 * 1000 });
await assertRejects(async () => { await assertRejects(async () => {
await db.enqueue("test", { delay: 7 * 24 * 60 * 60 * 1000 + 1 }); await db.enqueue("test", { delay: 30 * 24 * 60 * 60 * 1000 + 1 });
}, TypeError); }, TypeError);
}); });

View file

@ -26,14 +26,14 @@ async function openKv(path: string) {
return new Kv(rid, kvSymbol); return new Kv(rid, kvSymbol);
} }
const millisecondsInOneWeek = 7 * 24 * 60 * 60 * 1000; const maxQueueDelay = 30 * 24 * 60 * 60 * 1000;
function validateQueueDelay(delay: number) { function validateQueueDelay(delay: number) {
if (delay < 0) { if (delay < 0) {
throw new TypeError("delay cannot be negative"); throw new TypeError("delay cannot be negative");
} }
if (delay > millisecondsInOneWeek) { if (delay > maxQueueDelay) {
throw new TypeError("delay cannot be greater than one week"); throw new TypeError("delay cannot be greater than 30 days");
} }
if (isNaN(delay)) { if (isNaN(delay)) {
throw new TypeError("delay cannot be NaN"); throw new TypeError("delay cannot be NaN");