Expand description
PostgreSQL store for agent-effects.
For production services: many workers on many hosts sharing one database.
let store = agent_effects_postgres::PostgresStore::connect("postgres://localhost/effects").await?;§The database’s clock
By default (ClockSource::Database), every time the store uses comes
from Postgres’s clock_timestamp(), not from the calling worker:
- lease liveness, lease expiry and takeover;
- the times recorded on transitions;
- the “no live lease” filter of recovery scans.
Workers whose clocks disagree therefore still agree on who holds a lease.
This removes the clock-skew limit that leases otherwise have. Retry
schedules (next_attempt_at) are still computed by the worker.
ClockSource::Caller uses the times the runtime passes in instead, as
the in-memory and SQLite stores do; the conformance suite needs it to
drive time.
§Concurrency
Every change is “load the row FOR UPDATE, apply the pure
EffectRecord operation, save” in one transaction, so concurrent writers
serialize on the row. The update also checks the version it read.
Recovery and pending scans read with FOR UPDATE SKIP LOCKED: rows
another worker is changing right now are skipped, not waited on.
Structs§
- Postgres
Store - An
EffectStorein a PostgreSQL database.
Enums§
- Clock
Source - Whose clock the store trusts for leases and recorded times.