@@ -14,25 +14,37 @@ A complete example using Vorsteh Queue with Drizzle ORM and PGlite (embedded Pos
1414- ✅ ** Queue statistics** - Monitor queue health
1515- ✅ ** Graceful shutdown** - Clean termination
1616
17- ## Quick Start
17+ ## Setup
18+
19+ 1 . Install dependencies:
1820
1921``` bash
20- # Install dependencies
2122pnpm install
23+ ```
24+
25+ 2 . Push database schema:
2226
23- # Run the example
27+ ``` bash
28+ pnpm db:push
29+ ```
30+
31+ 3 . Run the example:
32+
33+ ``` bash
2434pnpm dev
2535```
2636
37+ > ** Note** : PGlite creates an embedded PostgreSQL database automatically, but the schema still needs to be initialized.
38+
2739## What It Does
2840
29411 . ** Creates embedded database** - PGlite starts with empty database
30- 2 . ** Sets up schema** - Creates queue tables automatically
31- 3 . ** Registers job handlers** - Email and data processing jobs
32- 4 . ** Adds various jobs** - Immediate, delayed, priority, and recurring
42+ 2 . ** Initializes schema** - Uses drizzle-kit pushSchema to create tables
43+ 3 . ** Registers job handlers** - Email and data processing jobs with TypeScript types
44+ 4 . ** Adds sample jobs** - Immediate, delayed, and priority jobs
33455 . ** Processes jobs** - Shows real-time progress and events
34- 6 . ** Displays stats** - Queue statistics every 5 seconds
35- 7 . ** Graceful shutdown** - Stops after 30 seconds
46+ 6 . ** Displays stats** - Queue statistics every 10 seconds
47+ 7 . ** Graceful shutdown** - Press Ctrl+C to stop cleanly
3648
3749## Perfect for Bug Reports
3850
@@ -47,38 +59,51 @@ This example is ideal for reproducing bugs because:
4759## Example Output
4860
4961```
50- 🚀 Starting PGlite Queue Example
51-
52- 📝 Adding jobs to queue...
62+ 🚀 Starting PGlite Queue Example (Embedded PostgreSQL)
63+ 📋 Initializing database schema...
64+ ✅ Database schema initialized
5365✅ Job added: send-email (abc123...)
54- ✅ Job added: send-email (def456...)
55- ✅ Job added: process-data (ghi789...)
56-
57- 🔄 Starting queue processing...
66+ ✅ Job added: process-data (def456...)
67+ ✅ Job added: send-email (ghi789...)
68+ 🔄 Queue processing started. Press Ctrl+C to stop.
5869⚡ Processing: send-email (abc123...)
59- 📧 Sending email to user@example.com
60- Subject: Welcome to Vorsteh Queue!
70+ 📧 Sending email to user@example.com: Welcome!
6171🎉 Completed: send-email (abc123...)
62-
63- 📊 Queue Stats: { pending: 2, processing: 0, completed: 1, failed: 0, delayed: 1 }
72+ ⚡ Processing: process-data (def456...)
73+ 📊 Processing 20 items in batches of 5
74+ 📈 Progress: process-data - 25%
75+ 📈 Progress: process-data - 50%
76+ 📊 Queue Stats: { pending: 1, processing: 1, completed: 1, failed: 0, delayed: 1 }
6477```
6578
6679## Job Types
6780
6881### Email Job
82+
6983``` typescript
7084interface EmailJob {
7185 to: string
72- subject: string
73- body: string
86+ subject: string
87+ body? : string
88+ }
89+
90+ interface EmailResult {
91+ sent: boolean
92+ messageId: string
7493}
7594```
7695
7796### Data Processing Job
97+
7898``` typescript
7999interface DataProcessingJob {
80- items: string []
81- batchSize: number
100+ data: unknown []
101+ batchSize? : number
102+ }
103+
104+ interface DataProcessingResult {
105+ processed: number
106+ results: unknown []
82107}
83108```
84109
@@ -95,4 +120,4 @@ interface DataProcessingJob {
95120- ** Bug reproduction** - Minimal setup for issue reports
96121- ** Feature testing** - Quick way to test new features
97122- ** Learning** - Understand how Vorsteh Queue works
98- - ** Prototyping** - Rapid development without database setup
123+ - ** Prototyping** - Rapid development without database setup
0 commit comments