quasar_postgres

Cluster-safe PostgreSQL durable Store.

Types

pub type MigrationError {
  MigrationUnavailable
  Database(pog.QueryError)
}

Constructors

Values

pub fn migrate(
  connection: pog.Connection,
) -> Result(Nil, MigrationError)

Applies all pending packaged migrations in version order.

The migration history and a shared advisory lock make concurrent startup safe when multiple application instances share one database. Migrations are applied strictly in version order; online migrations run outside a database transaction so PostgreSQL can execute CONCURRENTLY statements.

pub fn new(connection: pog.Connection) -> store.Store

Builds a Store backed by an existing Pog connection pool.

The Pog pool remains application-owned and is not stopped when this Store closes. Run migrate once before starting Quasar.

pub fn transactional_worker(
  connection: pog.Connection,
  name name: String,
  encode encode: fn(input) -> String,
  decode decode: fn(String) -> Result(input, String),
  perform perform: fn(input, worker.Context, pog.Connection) -> Result(
    Nil,
    String,
  ),
) -> worker.Worker(input)

Builds a worker whose PostgreSQL business effect and fenced job completion commit in the same transaction.

This is intentionally PostgreSQL-specific. Use a regular worker.new when effects live outside this database and make those effects idempotent.

Search Document