Key Features of PgQueuer
mainPgQueuer provides several built-in capabilities for job processing:
- Real-Time Delivery: Uses
LISTEN/NOTIFYfor instant job pushing to workers. - Concurrency Control: Use
concurrency_limiton an entrypoint to protect downstream services. A limit of1ensures strict serial processing globally. - Built-In Scheduler: Supports cron-style recurring tasks via the
@scheduledecorator (supports 5-field or 6-field expressions). - Automatic Retries & Heartbeat:
DatabaseRetryEntrypointExecutorhandles exponential backoff, while heartbeat monitoring re-queues jobs from crashed workers. - Observability: Includes Prometheus metrics, Logfire/Sentry tracing, and a live CLI dashboard via
pgq dashboard. - In-Memory Testing: Use
PgQueuer.in_memory()for unit tests without requiring a real PostgreSQL instance. - Completion Tracking:
CompletionWatcherallows callers to await job results viaLISTEN/NOTIFY. - Deferred Execution: Use
execute_afterto schedule jobs for a specific future timestamp. - Error Handling: Set
on_failure="hold"to park failed jobs for manual review. Usepgq failedto inspect andpgq requeue <id>to retry them. - MCP Server: An optional Model Context Protocol server provides read-only tools for queue size, throughput, failures, etc.