Docket.Postgres.Notifier (docket v0.1.0-dev)

Copy Markdown View Source

LISTEN fast path turning committed immediate-wake notifications into dispatcher polls.

The Postgres RunStore announces every committed due wake with pg_notify on the docket_wake channel, carrying the schema prefix (empty string when unprefixed) as payload. The notifier holds one dedicated LISTEN connection outside the Repo pool, and each notification whose payload matches its own context prefix requests one immediate dispatcher poll. Notification bursts collapse inside the dispatcher.

Polling remains the correctness mechanism. A lost notification, a dead listener, or an absent notifier only delays claiming until the dispatcher's next scheduled poll; omitting this child entirely is poll-only operation, where the dispatcher's poll interval alone bounds immediate-wake latency.

The LISTEN connection derives its options from the configured Repo, reconnects on its own, and re-subscribes after reconnecting. Notifications sent while it is disconnected are dropped. pg_notify emission is ordinary SQL inside the writer's transaction and works through any pooler, but LISTEN requires a session-scoped connection: behind PgBouncer in transaction or statement pooling mode, point :connection at a direct or session-pooled endpoint, or run poll-only.

Summary

Functions

Returns a specification to start this module under a supervisor.

Types

option()

@type option() ::
  {:name, GenServer.name()}
  | {:context, Docket.Backend.ctx()}
  | {:dispatcher, GenServer.server()}
  | {:connection, keyword()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link([option()]) :: GenServer.on_start()