A PostgreSQL-based oracle for leader election using database leases.
Uses a single table with atomic upserts to manage leadership leases. The table is created automatically (no migrations needed).
Options
:repo(required) - anEcto.Repomodule:duration(optional, default30) - lease duration in seconds:crown_name(injected by Crown) - used as the lock name
Example
{Crown,
name: :my_worker,
oracle: {Crown.Oracles.PostgresLease, repo: MyApp.Repo},
child_spec: MyApp.SingletonWorker}
Summary
Functions
Drops the leases table. Useful for test cleanup.