Jobs, events and notifications
Start with the OIDC deployment from the browser sign-in runbook. The default
deployment has events disabled. To turn on events, generate a separate 32-byte
key with openssl rand -base64 32 and supply it as REALTIME_TICKET_KEY to
each API replica. Configure APP_ORIGIN as the exact browser origin and
REALTIME_URL as the public WSS URL for /connection/websocket on the API.
The reverse proxy must support WebSocket upgrade. Keep Redis on a private
network. The example volume enables append-only persistence with fsync on
each write and disables key eviction. Use a dedicated, authenticated Redis
instance with appropriate recovery and availability settings for deployment.
Run the API with an embedded worker:
docker compose -f compose.yaml -f compose.identity.yaml -f compose.events.yaml up -dTo run independent workers with the same Redis and PostgreSQL databases:
EVENTS_MODE=standalone docker compose -f compose.yaml -f compose.identity.yaml -f compose.events.yaml --profile worker up -d --scale worker=2For a new local identity, the application commits the identity, welcome notification and job outbox row in one PostgreSQL transaction. With the worker offline, the inbox remains readable. After restart, the dispatcher enqueues outstanding events in Asynq using a stable task ID. Completed IDs are retained for 24 hours. A worker publishes an opaque change hint to the recipient through Centrifuge. The browser refetches the authenticated inbox on connect and after a hint. Socket credentials are short-lived and separate from the underlying access token. A reconnect or repeated event can trigger another fetch.
Delivery is at least once. Consumers that apply durable business changes must enforce idempotency in their own database transaction. Multiple workers can deliver events out of order. Temporary outbox failures back off. Inspect job_outbox rows with failed_at set for permanent failures. After fixing a rejected event's handler, an operator may clear failed_at and set available_at to now() for that specific row to retry it. Inspect Asynq archived tasks for exhausted retries. Validate the cause and the handler's idempotency before retrying. The durable inbox also supports recovery when Redis history expires.
Run sh tools/integration/check-events.sh with Docker Compose to exercise
commit and rollback, worker restarts and retries, duplicate handling, recipient
channel isolation, WebSocket recovery and delivery of a committed notification.