BullMQ.Backends.Postgres.Connection (BullMQ v2.0.2)

View Source

Owns the PostgreSQL connection resources for the BullMQ Postgres backend, mirroring BullMQ.RedisConnection:

  • a Postgrex connection pool for regular queries (each pooled connection pins its search_path to the configured schema, so the portable .sql files reference unqualified names), and
  • a dedicated Postgrex.Notifications process used by the blocking "wait for job" / event-stream primitives (LISTEN/NOTIFY).

Schema migrations are run exactly once at startup on the pool, guarded by a transaction-scoped advisory lock.

Options

  • :name (required) — name to register the connection under.
  • :url — a postgres://… connection string, or
  • :hostname/:port/:database/:username/:password — discrete opts.
  • :schema — the namespace for all queues (default "bullmq").
  • :pool_size — pool size (default 10).
  • :skip_version_check — bypass the minimum-server-version assertion.
  • :skip_migrations — do not run migrations (assume already applied).

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the connection pool and notifications.

Returns the connection context (%{pool, notifications, schema}) for name.

The Postgrex pool reference for name.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(name)

@spec close(atom()) :: :ok

Closes the connection pool and notifications.

context(name)

@spec context(atom()) :: %{pool: term(), notifications: term(), schema: String.t()}

Returns the connection context (%{pool, notifications, schema}) for name.

notifications(name)

The Postgrex.Notifications reference for name.

pool(name)

The Postgrex pool reference for name.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()