Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Add expireAt to idempotency lock to be able to configure TTL.
Browse files Browse the repository at this point in the history
Co-authored-by: Alice Boberg <[email protected]>
  • Loading branch information
MattiasOlla and aliceboberg committed Jan 22, 2024
1 parent 8344cca commit d6bf9a2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/job-storage/firestore-job-storage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Firestore from "@google-cloud/firestore";
import { Firestore } from "@google-cloud/firestore";

import { bucketHash, parentPayload, scanForInvalidKeys } from "./utils/job-storage-helper.js";
import buildLogger from "../logger.js";
Expand Down Expand Up @@ -111,7 +111,7 @@ async function messageAlreadySeen(idempotencyKey, deliveryAttempt) {
await db
.collection("idempotencyLocks")
.doc(`${idempotencyKey}:${deliveryAttempt}`)
.create({ idempotencyKey, deliveryAttempt });
.create({ idempotencyKey, deliveryAttempt, expireAt: new Date(Date.now() + 24 * 60 * 60 * 1000) });
return false;
} catch (err) {
if (err.code.toLowerCase() === "already-exists") {
Expand Down

0 comments on commit d6bf9a2

Please sign in to comment.