Pular para o conteúdo
Português (BR)

PostgresDurableStateStore

Este conteúdo não está disponível em sua língua ainda.

Defined in: src/persistence/durable-state-stores/PostgresDurableStateStore.ts:45

DurableStateStore backed by PostgreSQL (pg) — the first SQL-based durable-state store (SQLite / Cassandra ship journal + snapshot only).

One row per persistence_id, rewritten in place. Optimistic concurrency via the revision column:

  • expectedRevision === 0INSERT … ON CONFLICT DO NOTHING; zero rows affected means the row already exists → conflict.
  • expectedRevision > 0UPDATE … WHERE revision = expected; zero rows affected means the stored revision diverged → conflict.

On conflict the current revision is read back and reported in the DurableStateConcurrencyError. PersistenceOptions are ignored (JSON-text payload, like the other SQL stores).

new PostgresDurableStateStore(options?): PostgresDurableStateStore

Defined in: src/persistence/durable-state-stores/PostgresDurableStateStore.ts:54

PostgresDurableStateStoreOptions = {}

PostgresDurableStateStore

close(): Promise<void>

Defined in: src/persistence/durable-state-stores/PostgresDurableStateStore.ts:126

Promise<void>


delete(persistenceId): Promise<void>

Defined in: src/persistence/durable-state-stores/PostgresDurableStateStore.ts:121

Remove the record entirely. Idempotent.

string

Promise<void>

DurableStateStore.delete


load<S>(persistenceId, _options?): Promise<Option<DurableStateRecord<S>>>

Defined in: src/persistence/durable-state-stores/PostgresDurableStateStore.ts:105

Load the latest record for persistenceId, or None if none exists. options.encryption is required when client-side encryption was used at write time.

S

string

PersistenceOptions

Promise<Option<DurableStateRecord<S>>>

DurableStateStore.load


upsert<S>(persistenceId, expectedRevision, state, _options?): Promise<DurableStateRecord<S>>

Defined in: src/persistence/durable-state-stores/PostgresDurableStateStore.ts:60

Upsert the state for persistenceId. expectedRevision must match the current stored revision (0 when no record exists yet). Throws DurableStateConcurrencyError on conflict. Optional options carry per-call preferences from the caller (e.g. compression / encryption set on the actor); stores that cannot honour them silently ignore the field.

S

string

number

S

PersistenceOptions

Promise<DurableStateRecord<S>>

DurableStateStore.upsert