BullMQ.Backends.Postgres (BullMQ v2.0.2)
View SourcePostgreSQL implementation of the BullMQ.Backend behaviour — the Elixir port
of the Node.js PostgresQueueBackend.
The heavy lifting lives in language-agnostic SQL: the schema and PL/pgSQL
operation functions are applied by BullMQ.Backends.Postgres.Migrator from
the shared src/postgres/migrations/*.sql, and every runtime operation runs a
parameterized statement from src/postgres/commands/*.sql (loaded by
BullMQ.Backends.Postgres.SqlLoader). This adapter only builds the parameter
lists and maps result rows into the same shapes the high-level BullMQ modules
already consume from the Redis backend.
The connection-level schema is the namespace for all queues (the SQL-native
replacement for Redis's per-queue key prefix), so the .sql files reference
unqualified names and stay portable.
Usage
{:ok, _} = BullMQ.Backends.Postgres.Connection.start_link(
name: :pg, url: "postgres://localhost/bullmq", schema: "bullmq")
# Point BullMQ at the Postgres backend, then use Queue/Worker as usual:
{:ok, _} = BullMQ.Queue.add("emails", "welcome", %{},
connection: :pg, backend: BullMQ.Backends.Postgres)
Summary
Types
Functions
Builds a Postgres backend for the queue name.
Options
:connection(required) — a startedBullMQ.Backends.Postgres.Connection.:owns_connection— whetherclose/2stops the connection (defaulttrue).