PG Boss
The pg-boss runtime provides PostgreSQL-based job queue processing with robust persistence, transactions, and reliability features.
Live Exampleβ
Overviewβ
pg-boss provides:
- PostgreSQL-backed queues for ACID-compliant job processing
- Built-in persistence with automatic table creation
- Job retries with configurable limits
- Batch processing for high-throughput scenarios
- Graceful shutdown with proper cleanup
- Job results tracking with full status monitoring
Quick Startβ
1. Create a New Projectβ
Create a new Pikku project with pg-boss support:
npm create pikku@latest
Select pg-boss as your runtime option during setup.
Project Structureβ
After creating your project, you'll have these key files:
Queue Worker Functionsβ
Define your job processing logic (same as other queue systems):
queue-worker.functions.ts
loading...
Queue Worker Registrationβ
Register workers with specific queues:
queue-worker.routes.ts
loading...
pg-boss Runtime Serverβ
The main server that processes jobs using PostgreSQL:
start.ts
loading...
Setup Guideβ
Complete setup instructions:
README.md
loading...
How It Worksβ
- Database Connection: Connects to PostgreSQL using
DATABASE_URL
- Auto Schema: Creates necessary tables automatically on startup
- Job Processing: Polls PostgreSQL for new jobs and distributes to workers
- ACID Compliance: All job operations are transactional