Μετάβαση στο περιεχόμενο

PostgresIdempotencyStore

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:142

IdempotencyStore backed by Postgres (pg) — a drop-in replacement that shares state across instances without a separate Redis.

Create the table once with createIdempotencyTableSql. Atomicity of setIfAbsent comes from a conditional INSERT … ON CONFLICT … DO UPDATE: an absent key is inserted, an expired key is atomically replaced, and a live conflict is left untouched. Completion/release also compare claim_id in the same SQL statement, so a stale execution cannot mutate a newer claim. The table name is validated as a plain SQL identifier (it is interpolated, not parameterized); all values are passed as bound parameters.

import { Pool } from 'pg';
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
await pool.query(createIdempotencyTableSql());
const store = new PostgresIdempotencyStore(pool);

new PostgresIdempotencyStore(db, options?): PostgresIdempotencyStore

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:145

PostgresQueryableLike

PostgresIdempotencyStoreOptions = {}

PostgresIdempotencyStore

completeIfOwned(key, claimId, record, ttlMs): Promise<boolean>

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:191

Atomically replaces the live in_progress record with record only when the existing record is still owned by claimId.

string

string

IdempotencyRecord

number

Promise<boolean>

true when this claim completed its own record; false when the claim expired, was replaced, or was otherwise no longer owned by the caller.

IdempotencyStore.completeIfOwned


delete(key): Promise<void>

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:253

Unconditional delete for administrative or custom use. Pipeline failure release uses deleteIfOwned, not this method.

string

Promise<void>

IdempotencyStore.delete


deleteIfOwned(key, claimId): Promise<boolean>

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:218

Atomically removes the live record only when it is still owned by claimId. Used by releaseOnError so a stale failure cannot delete a newer execution’s claim.

string

string

Promise<boolean>

IdempotencyStore.deleteIfOwned


get(key): Promise<IdempotencyRecord | undefined>

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:152

Returns the live (non-expired) record for key, or undefined if there is none.

string

Promise<IdempotencyRecord | undefined>

IdempotencyStore.get


set(key, record, ttlMs): Promise<void>

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:230

Unconditional overwrite for administrative or custom use. Pipeline execution completion uses completeIfOwned, not this method.

string

IdempotencyRecord

number

Promise<void>

IdempotencyStore.set


setIfAbsent(key, record, ttlMs): Promise<boolean>

Defined in: packages/pipeline-idempotency/src/stores/postgres.store.ts:165

Atomically stores record only if no live record exists for key.

string

IdempotencyRecord

number

Promise<boolean>

true if the key was claimed by this call, false if a live record already existed.

IdempotencyStore.setIfAbsent