light-async-queue 1.1.0 â 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +310 -30
- package/dist/src/constants.d.ts +24 -5
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +20 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/dashboard/Dashboard.d.ts +70 -0
- package/dist/src/dashboard/Dashboard.d.ts.map +1 -0
- package/dist/src/dashboard/Dashboard.js +308 -0
- package/dist/src/dashboard/Dashboard.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +3 -0
- package/dist/src/dashboard/index.d.ts.map +1 -0
- package/dist/src/dashboard/index.js +2 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/index.d.ts +13 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/queue/Job.d.ts +35 -4
- package/dist/src/queue/Job.d.ts.map +1 -1
- package/dist/src/queue/Job.js +92 -8
- package/dist/src/queue/Job.js.map +1 -1
- package/dist/src/queue/Queue.d.ts +73 -3
- package/dist/src/queue/Queue.d.ts.map +1 -1
- package/dist/src/queue/Queue.js +357 -35
- package/dist/src/queue/Queue.js.map +1 -1
- package/dist/src/queue/Scheduler.d.ts.map +1 -1
- package/dist/src/queue/Scheduler.js +8 -1
- package/dist/src/queue/Scheduler.js.map +1 -1
- package/dist/src/storage/FileStore.js +4 -4
- package/dist/src/storage/FileStore.js.map +1 -1
- package/dist/src/types.d.ts +79 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/CronParser.d.ts +12 -0
- package/dist/src/utils/CronParser.d.ts.map +1 -0
- package/dist/src/utils/CronParser.js +28 -0
- package/dist/src/utils/CronParser.js.map +1 -0
- package/dist/src/utils/RateLimiter.d.ts +37 -0
- package/dist/src/utils/RateLimiter.d.ts.map +1 -0
- package/dist/src/utils/RateLimiter.js +68 -0
- package/dist/src/utils/RateLimiter.js.map +1 -0
- package/dist/src/utils/WebhookManager.d.ts +29 -0
- package/dist/src/utils/WebhookManager.d.ts.map +1 -0
- package/dist/src/utils/WebhookManager.js +82 -0
- package/dist/src/utils/WebhookManager.js.map +1 -0
- package/dist/src/worker/Worker.d.ts +2 -2
- package/dist/src/worker/Worker.d.ts.map +1 -1
- package/dist/src/worker/Worker.js +57 -36
- package/dist/src/worker/Worker.js.map +1 -1
- package/dist/src/worker/childProcessor.js +17 -1
- package/dist/src/worker/childProcessor.js.map +1 -1
- package/package.json +27 -5
package/README.md
CHANGED
|
@@ -7,19 +7,34 @@
|
|
|
7
7
|
[](https://nodejs.org)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
9
|
|
|
10
|
-
A production-ready, Redis-free async job queue for Node.js with TypeScript.
|
|
10
|
+
A production-ready, **Redis-free** async job queue for Node.js with TypeScript. A powerful BullMQ alternative designed for single-node reliability with file-based persistence, worker process isolation, and enterprise-grade features.
|
|
11
11
|
|
|
12
12
|
## âĻ Features
|
|
13
13
|
|
|
14
|
+
### Core Features
|
|
15
|
+
|
|
14
16
|
- **ð Reliable Job Processing** - File-based persistence with crash recovery
|
|
15
17
|
- **ð· Worker Isolation** - Jobs execute in separate child processes using `child_process.fork()`
|
|
16
18
|
- **ð Smart Retry Logic** - Exponential backoff with configurable attempts
|
|
17
19
|
- **ð Dead Letter Queue** - Failed jobs are preserved and can be reprocessed
|
|
18
20
|
- **⥠Concurrency Control** - Configurable parallel job execution
|
|
19
21
|
- **ðĄïļ Graceful Shutdown** - Waits for active jobs before exiting
|
|
20
|
-
- **ð Queue Statistics** - Monitor active, pending, completed, and failed jobs
|
|
21
22
|
- **ðŊ TypeScript First** - Full type safety with no `any` types
|
|
22
|
-
- **ðŠķ
|
|
23
|
+
- **ðŠķ Minimal Dependencies** - Only 2 runtime dependencies (`cron-parser`, `ws`)
|
|
24
|
+
|
|
25
|
+
### Advanced Features (BullMQ Compatible)
|
|
26
|
+
|
|
27
|
+
- **ðĒ Job Events** - Listen to waiting, active, completed, failed, progress, stalled events
|
|
28
|
+
- **â° Delayed Jobs** - Schedule jobs to run after a delay
|
|
29
|
+
- **ð Repeating Jobs** - Interval-based and cron-pattern recurring jobs
|
|
30
|
+
- **ðŊ Job Priorities** - High-priority jobs run first
|
|
31
|
+
- **ð Progress Tracking** - Real-time job progress updates
|
|
32
|
+
- **ð Job Dependencies** - Jobs can wait for other jobs to complete
|
|
33
|
+
- **⥠Rate Limiting** - Control job execution rate
|
|
34
|
+
- **ð Webhooks** - HTTP callbacks for job events
|
|
35
|
+
- **âąïļ Stalled Job Detection** - Automatically detect and handle stuck jobs
|
|
36
|
+
- **ð Enhanced Metrics** - Detailed queue statistics by job status
|
|
37
|
+
- **ðĨïļ HTML Dashboard** - Real-time web UI for monitoring (Zookeeper-style)
|
|
23
38
|
|
|
24
39
|
## ðĶ Installation
|
|
25
40
|
|
|
@@ -91,7 +106,11 @@ Create a new queue instance.
|
|
|
91
106
|
**Config Options:**
|
|
92
107
|
|
|
93
108
|
```typescript
|
|
94
|
-
import {
|
|
109
|
+
import {
|
|
110
|
+
StorageType,
|
|
111
|
+
BackoffStrategyType,
|
|
112
|
+
QueueEventType,
|
|
113
|
+
} from "light-async-queue";
|
|
95
114
|
|
|
96
115
|
interface QueueConfig {
|
|
97
116
|
storage: StorageType;
|
|
@@ -104,32 +123,183 @@ interface QueueConfig {
|
|
|
104
123
|
delay: number; // Base delay in ms
|
|
105
124
|
};
|
|
106
125
|
};
|
|
126
|
+
rateLimiter?: {
|
|
127
|
+
max: number; // Max jobs
|
|
128
|
+
duration: number; // Per duration in ms
|
|
129
|
+
};
|
|
130
|
+
webhooks?: Array<{
|
|
131
|
+
url: string;
|
|
132
|
+
events: QueueEventType[];
|
|
133
|
+
headers?: Record<string, string>;
|
|
134
|
+
}>;
|
|
135
|
+
stalledInterval?: number; // Check for stalled jobs every X ms (default: 30000)
|
|
107
136
|
}
|
|
108
137
|
```
|
|
109
138
|
|
|
110
139
|
### `queue.process(processor)`
|
|
111
140
|
|
|
112
|
-
Set the job processor function.
|
|
141
|
+
Set the job processor function with progress tracking support.
|
|
113
142
|
|
|
114
143
|
```typescript
|
|
115
|
-
queue.process(async (job
|
|
116
|
-
//
|
|
117
|
-
|
|
144
|
+
queue.process(async (job) => {
|
|
145
|
+
// Access job data
|
|
146
|
+
console.log(job.payload);
|
|
147
|
+
|
|
148
|
+
// Report progress
|
|
149
|
+
await job.updateProgress(50);
|
|
150
|
+
|
|
151
|
+
// Log messages
|
|
152
|
+
job.log("Processing step 1");
|
|
153
|
+
|
|
154
|
+
// Return result
|
|
155
|
+
return { success: true };
|
|
118
156
|
});
|
|
119
157
|
```
|
|
120
158
|
|
|
121
|
-
### `queue.add(payload)`
|
|
159
|
+
### `queue.add(payload, options?)`
|
|
122
160
|
|
|
123
|
-
Add a job to the queue.
|
|
161
|
+
Add a job to the queue with advanced options.
|
|
124
162
|
|
|
125
163
|
```typescript
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
164
|
+
// Simple job
|
|
165
|
+
const jobId = await queue.add({ userId: 123 });
|
|
166
|
+
|
|
167
|
+
// Job with priority (higher = more important)
|
|
168
|
+
await queue.add({ urgent: true }, { priority: 10 });
|
|
169
|
+
|
|
170
|
+
// Delayed job (runs after delay)
|
|
171
|
+
await queue.add({ task: "cleanup" }, { delay: 5000 });
|
|
172
|
+
|
|
173
|
+
// Repeating job (every X milliseconds)
|
|
174
|
+
await queue.add(
|
|
175
|
+
{ type: "heartbeat" },
|
|
176
|
+
{
|
|
177
|
+
repeat: {
|
|
178
|
+
every: 60000, // Every minute
|
|
179
|
+
limit: 100, // Max 100 repetitions
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// Cron-style repeating job
|
|
185
|
+
await queue.add(
|
|
186
|
+
{ type: "daily-report" },
|
|
187
|
+
{
|
|
188
|
+
repeat: {
|
|
189
|
+
pattern: "0 0 * * *", // Every day at midnight
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
// Job with dependencies
|
|
195
|
+
const job1 = await queue.add({ step: 1 });
|
|
196
|
+
await queue.add({ step: 2 }, { dependsOn: [job1] });
|
|
197
|
+
|
|
198
|
+
// Custom job ID
|
|
199
|
+
await queue.add({ data: "test" }, { jobId: "custom-id-123" });
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Queue Events
|
|
203
|
+
|
|
204
|
+
Listen to job lifecycle events:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { QueueEventType } from "light-async-queue";
|
|
208
|
+
|
|
209
|
+
queue.on(QueueEventType.WAITING, (job) => {
|
|
210
|
+
console.log("Job waiting for dependencies:", job.id);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
queue.on(QueueEventType.DELAYED, (job) => {
|
|
214
|
+
console.log("Job delayed until:", new Date(job.nextRunAt));
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
queue.on(QueueEventType.ACTIVE, (job) => {
|
|
218
|
+
console.log("Job started:", job.id);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
queue.on(QueueEventType.PROGRESS, (job, progress) => {
|
|
222
|
+
console.log(`Job ${job.id} progress: ${progress}%`);
|
|
129
223
|
});
|
|
224
|
+
|
|
225
|
+
queue.on(QueueEventType.COMPLETED, (job, result) => {
|
|
226
|
+
console.log("Job completed:", job.id, result);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
queue.on(QueueEventType.FAILED, (job, error) => {
|
|
230
|
+
console.error("Job failed:", job.id, error.message);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
queue.on(QueueEventType.STALLED, (job) => {
|
|
234
|
+
console.warn("Job appears stalled:", job.id);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
queue.on(QueueEventType.DRAINED, () => {
|
|
238
|
+
console.log("Queue drained - all jobs processed");
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
queue.on(QueueEventType.ERROR, (error) => {
|
|
242
|
+
console.error("Queue error:", error);
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Queue Methods
|
|
247
|
+
|
|
248
|
+
#### `queue.getJob(jobId)`
|
|
249
|
+
|
|
250
|
+
Get a specific job by ID.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
const job = await queue.getJob("job-id-123");
|
|
254
|
+
if (job) {
|
|
255
|
+
console.log(job.status, job.progress);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### `queue.removeJob(jobId)`
|
|
260
|
+
|
|
261
|
+
Remove a specific job (only if not currently active).
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
const removed = await queue.removeJob("job-id-123");
|
|
130
265
|
```
|
|
131
266
|
|
|
132
|
-
|
|
267
|
+
#### `queue.pause()`
|
|
268
|
+
|
|
269
|
+
Pause job processing.
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
queue.pause();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### `queue.resume()`
|
|
276
|
+
|
|
277
|
+
Resume job processing.
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
queue.resume();
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### `queue.drain()`
|
|
284
|
+
|
|
285
|
+
Wait for all pending jobs to be processed.
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
await queue.drain();
|
|
289
|
+
console.log("All jobs completed!");
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### `queue.clean(maxAge)`
|
|
293
|
+
|
|
294
|
+
Remove completed jobs older than maxAge (in milliseconds).
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
// Clean jobs older than 24 hours
|
|
298
|
+
const cleaned = await queue.clean(24 * 60 * 60 * 1000);
|
|
299
|
+
console.log(`Cleaned ${cleaned} old jobs`);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
#### `queue.getFailedJobs()`
|
|
133
303
|
|
|
134
304
|
Get all jobs in the Dead Letter Queue.
|
|
135
305
|
|
|
@@ -137,7 +307,7 @@ Get all jobs in the Dead Letter Queue.
|
|
|
137
307
|
const failedJobs = await queue.getFailedJobs();
|
|
138
308
|
```
|
|
139
309
|
|
|
140
|
-
|
|
310
|
+
#### `queue.reprocessFailed(jobId)`
|
|
141
311
|
|
|
142
312
|
Reprocess a failed job from the DLQ.
|
|
143
313
|
|
|
@@ -145,21 +315,24 @@ Reprocess a failed job from the DLQ.
|
|
|
145
315
|
await queue.reprocessFailed("job-id-here");
|
|
146
316
|
```
|
|
147
317
|
|
|
148
|
-
|
|
318
|
+
#### `queue.getStats()`
|
|
149
319
|
|
|
150
|
-
Get queue statistics.
|
|
320
|
+
Get enhanced queue statistics.
|
|
151
321
|
|
|
152
322
|
```typescript
|
|
153
323
|
const stats = await queue.getStats();
|
|
154
324
|
// {
|
|
155
325
|
// active: 2,
|
|
326
|
+
// waiting: 1,
|
|
327
|
+
// delayed: 3,
|
|
156
328
|
// pending: 5,
|
|
157
329
|
// completed: 100,
|
|
158
|
-
// failed: 3
|
|
330
|
+
// failed: 3,
|
|
331
|
+
// stalled: 0
|
|
159
332
|
// }
|
|
160
333
|
```
|
|
161
334
|
|
|
162
|
-
|
|
335
|
+
#### `queue.shutdown()`
|
|
163
336
|
|
|
164
337
|
Gracefully shutdown the queue.
|
|
165
338
|
|
|
@@ -263,16 +436,106 @@ The queue handles `SIGINT` and `SIGTERM` signals:
|
|
|
263
436
|
await queue.shutdown();
|
|
264
437
|
```
|
|
265
438
|
|
|
266
|
-
##
|
|
439
|
+
## ïŋ―ïļ HTML Dashboard - Real-Time Monitoring
|
|
440
|
+
|
|
441
|
+
### ðĨ Demo Video
|
|
442
|
+
https://github.com/user-attachments/assets/a122ba9d-dcf5-4c21-9e92-99c8847ae836
|
|
443
|
+
|
|
444
|
+
Light Async Queue includes a built-in HTML dashboard for real-time monitoring, similar to Zookeeper. The dashboard provides a modern, responsive web interface for tracking job statuses and managing your queue.
|
|
445
|
+
|
|
446
|
+
### Quick Start
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { Queue, Dashboard, StorageType } from "light-async-queue";
|
|
450
|
+
|
|
451
|
+
const queue = new Queue({
|
|
452
|
+
storage: StorageType.FILE,
|
|
453
|
+
filePath: "./jobs.log",
|
|
454
|
+
concurrency: 3,
|
|
455
|
+
retry: {
|
|
456
|
+
/* ... */
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// Create and start dashboard
|
|
461
|
+
const dashboard = new Dashboard(queue, {
|
|
462
|
+
port: 3000,
|
|
463
|
+
host: "localhost",
|
|
464
|
+
updateInterval: 1000, // Update every 1 second
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
await dashboard.start();
|
|
468
|
+
console.log("ð Dashboard: http://localhost:3000");
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Dashboard Features
|
|
472
|
+
|
|
473
|
+
- **ð Real-time Statistics** - Live job counts (active, waiting, delayed, pending, completed, failed, stalled)
|
|
474
|
+
- **ð Job Tracking** - View active/waiting jobs with progress bars
|
|
475
|
+
- **â ïļ Dead Letter Queue** - Monitor and retry failed jobs from the UI
|
|
476
|
+
- **ð WebSocket Updates** - Fast, real-time data synchronization
|
|
477
|
+
- **ðĻ Modern UI** - Responsive design with color-coded status badges
|
|
478
|
+
- **ð Progress Visualization** - Track job completion with visual indicators
|
|
479
|
+
|
|
480
|
+
### API Endpoints
|
|
481
|
+
|
|
482
|
+
The dashboard exposes REST API endpoints:
|
|
483
|
+
|
|
484
|
+
- `GET /` - HTML dashboard interface
|
|
485
|
+
- `GET /api/stats` - Queue statistics (JSON)
|
|
486
|
+
- `GET /api/jobs` - Active and waiting jobs
|
|
487
|
+
- `GET /api/failed-jobs` - Failed jobs in DLQ
|
|
488
|
+
- `POST /api/reprocess-failed` - Retry a failed job
|
|
489
|
+
|
|
490
|
+
### Example Usage
|
|
267
491
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
492
|
+
See the [complete dashboard example](./example/dashboard-example.ts) for a working implementation with:
|
|
493
|
+
|
|
494
|
+
- Real-time job processing
|
|
495
|
+
- Progress tracking
|
|
496
|
+
- Event handling
|
|
497
|
+
- Failed job retry from UI
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
# Run the example
|
|
501
|
+
npm run build:examples
|
|
502
|
+
node dist/example/dashboard-example.js
|
|
503
|
+
# Open http://localhost:3000
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
For detailed dashboard documentation, see [Dashboard README](./src/dashboard/README.md).
|
|
507
|
+
|
|
508
|
+
## ïŋ―ð Comparison with BullMQ and Bull
|
|
509
|
+
|
|
510
|
+
| Feature | light-async-queue | BullMQ | Bull |
|
|
511
|
+
| ----------------- | ----------------------------- | ---------------- | --------------- |
|
|
512
|
+
| Redis Required | â No | â
Yes | â
Yes |
|
|
513
|
+
| File Persistence | â
Yes | â No | â No |
|
|
514
|
+
| Worker Isolation | â
Child Process | â ïļ Same Process | â ïļ Same Process |
|
|
515
|
+
| Crash Recovery | â
Built-in | â ïļ Needs Redis | â ïļ Needs Redis |
|
|
516
|
+
| Job Events | â
Yes | â
Yes | â
Yes |
|
|
517
|
+
| Job Priorities | â
Yes | â
Yes | â
Yes |
|
|
518
|
+
| Delayed Jobs | â
Yes | â
Yes | â
Yes |
|
|
519
|
+
| Repeating Jobs | â
Yes | â
Yes | â
Yes |
|
|
520
|
+
| Cron Patterns | â
Yes | â
Yes | â
Yes |
|
|
521
|
+
| Job Dependencies | â
Yes | â
Yes | â No |
|
|
522
|
+
| Progress Tracking | â
Yes | â
Yes | â
Yes |
|
|
523
|
+
| Rate Limiting | â
Yes | â
Yes | â
Yes |
|
|
524
|
+
| Webhooks | â
Yes | â No | â No |
|
|
525
|
+
| Stalled Detection | â
Yes | â
Yes | â
Yes |
|
|
526
|
+
| HTML Dashboard | â
Built-in | â ïļ Bull Board | â ïļ Bull Board |
|
|
527
|
+
| Setup Complexity | ðĒ Low | ðĄ Medium | ðĄ Medium |
|
|
528
|
+
| Dependencies | ðĒ Minimal (cron-parser + ws) | ðī Redis + deps | ðī Redis + deps |
|
|
529
|
+
| Best For | Single-node apps | Distributed apps | Legacy apps |
|
|
530
|
+
|
|
531
|
+
**Why choose light-async-queue?**
|
|
532
|
+
|
|
533
|
+
- â
No Redis infrastructure or maintenance
|
|
534
|
+
- â
Built-in crash recovery with file persistence
|
|
535
|
+
- â
True process isolation for better fault tolerance
|
|
536
|
+
- â
Minimal runtime dependencies (`cron-parser`, `ws`)
|
|
537
|
+
- â
Perfect for edge deployments, serverless, or single-server apps
|
|
538
|
+
- â
All BullMQ features without the complexity
|
|
276
539
|
|
|
277
540
|
## ðŊ Use Cases
|
|
278
541
|
|
|
@@ -281,7 +544,7 @@ Perfect for:
|
|
|
281
544
|
- **Single-server applications** that don't need Redis
|
|
282
545
|
- **Background job processing** (emails, reports, etc.)
|
|
283
546
|
- **Reliable task queues** with crash recovery
|
|
284
|
-
- **Development environments**
|
|
547
|
+
- **Development environments** with minimal external dependencies
|
|
285
548
|
- **Edge deployments** where Redis isn't available
|
|
286
549
|
|
|
287
550
|
## ð§ Advanced Example
|
|
@@ -357,10 +620,27 @@ npm run build
|
|
|
357
620
|
npm run example
|
|
358
621
|
```
|
|
359
622
|
|
|
360
|
-
**Test Results:** â
|
|
623
|
+
**Test Results:** â
85+ tests passing across 8 test suites (powered by Vitest)
|
|
361
624
|
|
|
362
625
|
See [TEST_SUITE.md](./TEST_SUITE.md) for detailed test documentation.
|
|
363
626
|
|
|
627
|
+
## ð Examples
|
|
628
|
+
|
|
629
|
+
Check out the `example/` directory for comprehensive examples:
|
|
630
|
+
|
|
631
|
+
- **[basic.ts](./example/basic.ts)** - Simple queue setup and job processing
|
|
632
|
+
- **[concurrency.ts](./example/concurrency.ts)** - Concurrent job processing
|
|
633
|
+
- **[crash-recovery.ts](./example/crash-recovery.ts)** - Crash recovery demonstration
|
|
634
|
+
- **[advanced-features.ts](./example/advanced-features.ts)** - All BullMQ-compatible features:
|
|
635
|
+
- Job events and listeners
|
|
636
|
+
- Job priorities
|
|
637
|
+
- Delayed and repeating jobs
|
|
638
|
+
- Cron patterns
|
|
639
|
+
- Job dependencies
|
|
640
|
+
- Progress tracking
|
|
641
|
+
- Rate limiting
|
|
642
|
+
- Webhooks
|
|
643
|
+
|
|
364
644
|
## ð License
|
|
365
645
|
|
|
366
646
|
MIT
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
* Represents the different states a job can be in
|
|
4
4
|
*/
|
|
5
5
|
export declare enum JobStatus {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
WAITING = "waiting",// Waiting to be picked up (new default)
|
|
7
|
+
DELAYED = "delayed",// Scheduled for future execution
|
|
8
|
+
PENDING = "pending",// Ready to be processed
|
|
9
|
+
PROCESSING = "processing",// Currently being processed
|
|
10
|
+
COMPLETED = "completed",// Successfully completed
|
|
11
|
+
FAILED = "failed",// Failed after all retries
|
|
12
|
+
STALLED = "stalled"
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* Backoff Strategy Type Enum
|
|
@@ -44,6 +47,22 @@ export declare enum WorkerResponseType {
|
|
|
44
47
|
* Special signals for worker communication
|
|
45
48
|
*/
|
|
46
49
|
export declare enum WorkerSignalType {
|
|
47
|
-
READY = "ready"
|
|
50
|
+
READY = "ready",
|
|
51
|
+
PROGRESS = "progress"
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Queue Event Type Enum
|
|
55
|
+
* Events emitted by the queue
|
|
56
|
+
*/
|
|
57
|
+
export declare enum QueueEventType {
|
|
58
|
+
WAITING = "waiting",
|
|
59
|
+
DELAYED = "delayed",
|
|
60
|
+
ACTIVE = "active",
|
|
61
|
+
PROGRESS = "progress",
|
|
62
|
+
COMPLETED = "completed",
|
|
63
|
+
FAILED = "failed",
|
|
64
|
+
STALLED = "stalled",
|
|
65
|
+
DRAINED = "drained",
|
|
66
|
+
ERROR = "error"
|
|
48
67
|
}
|
|
49
68
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,SAAS;IACnB,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,SAAS;IACnB,OAAO,YAAY,CAAO,wCAAwC;IAClE,OAAO,YAAY,CAAO,iCAAiC;IAC3D,OAAO,YAAY,CAAO,wBAAwB;IAClD,UAAU,eAAe,CAAE,4BAA4B;IACvD,SAAS,cAAc,CAAI,yBAAyB;IACpD,MAAM,WAAW,CAAU,2BAA2B;IACtD,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,oBAAY,mBAAmB;IAC7B,WAAW,gBAAgB;IAC3B,KAAK,UAAU;CAChB;AAED;;;GAGG;AACH,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED;;;GAGG;AACH,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,aAAa,iBAAiB;CAC/B;AAED;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,QAAQ,aAAa;CACtB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB"}
|
package/dist/src/constants.js
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export var JobStatus;
|
|
6
6
|
(function (JobStatus) {
|
|
7
|
+
JobStatus["WAITING"] = "waiting";
|
|
8
|
+
JobStatus["DELAYED"] = "delayed";
|
|
7
9
|
JobStatus["PENDING"] = "pending";
|
|
8
10
|
JobStatus["PROCESSING"] = "processing";
|
|
9
11
|
JobStatus["COMPLETED"] = "completed";
|
|
10
12
|
JobStatus["FAILED"] = "failed";
|
|
13
|
+
JobStatus["STALLED"] = "stalled";
|
|
11
14
|
})(JobStatus || (JobStatus = {}));
|
|
12
15
|
/**
|
|
13
16
|
* Backoff Strategy Type Enum
|
|
@@ -51,5 +54,22 @@ export var WorkerResponseType;
|
|
|
51
54
|
export var WorkerSignalType;
|
|
52
55
|
(function (WorkerSignalType) {
|
|
53
56
|
WorkerSignalType["READY"] = "ready";
|
|
57
|
+
WorkerSignalType["PROGRESS"] = "progress";
|
|
54
58
|
})(WorkerSignalType || (WorkerSignalType = {}));
|
|
59
|
+
/**
|
|
60
|
+
* Queue Event Type Enum
|
|
61
|
+
* Events emitted by the queue
|
|
62
|
+
*/
|
|
63
|
+
export var QueueEventType;
|
|
64
|
+
(function (QueueEventType) {
|
|
65
|
+
QueueEventType["WAITING"] = "waiting";
|
|
66
|
+
QueueEventType["DELAYED"] = "delayed";
|
|
67
|
+
QueueEventType["ACTIVE"] = "active";
|
|
68
|
+
QueueEventType["PROGRESS"] = "progress";
|
|
69
|
+
QueueEventType["COMPLETED"] = "completed";
|
|
70
|
+
QueueEventType["FAILED"] = "failed";
|
|
71
|
+
QueueEventType["STALLED"] = "stalled";
|
|
72
|
+
QueueEventType["DRAINED"] = "drained";
|
|
73
|
+
QueueEventType["ERROR"] = "error";
|
|
74
|
+
})(QueueEventType || (QueueEventType = {}));
|
|
55
75
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;IACnB,sCAAyB,CAAA;IACzB,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;AACrB,CAAC,EARW,SAAS,KAAT,SAAS,QAQpB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,kDAA2B,CAAA;IAC3B,sCAAe,CAAA;AACjB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;AACf,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,mDAA8B,CAAA;AAChC,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;AACnB,CAAC,EAFW,kBAAkB,KAAlB,kBAAkB,QAE7B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,yCAAqB,CAAA;AACvB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,uCAAqB,CAAA;IACrB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,iCAAe,CAAA;AACjB,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Queue } from "../queue/Queue.js";
|
|
2
|
+
export interface DashboardConfig {
|
|
3
|
+
port: number;
|
|
4
|
+
host?: string;
|
|
5
|
+
updateInterval?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class Dashboard {
|
|
8
|
+
private queue;
|
|
9
|
+
private server;
|
|
10
|
+
private wss;
|
|
11
|
+
private updateInterval;
|
|
12
|
+
private config;
|
|
13
|
+
private clients;
|
|
14
|
+
private htmlTemplate;
|
|
15
|
+
constructor(queue: Queue, config: DashboardConfig);
|
|
16
|
+
/**
|
|
17
|
+
* Start the dashboard server
|
|
18
|
+
*/
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Stop the dashboard server
|
|
22
|
+
*/
|
|
23
|
+
stop(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Handle HTTP requests
|
|
26
|
+
*/
|
|
27
|
+
private handleRequest;
|
|
28
|
+
/**
|
|
29
|
+
* Serve the HTML dashboard
|
|
30
|
+
*/
|
|
31
|
+
private serveHTML;
|
|
32
|
+
/**
|
|
33
|
+
* Generate HTML dashboard
|
|
34
|
+
*/
|
|
35
|
+
private generateHTML;
|
|
36
|
+
private loadTemplate;
|
|
37
|
+
/**
|
|
38
|
+
* Setup WebSocket handlers
|
|
39
|
+
*/
|
|
40
|
+
private setupWebSocketHandlers;
|
|
41
|
+
/**
|
|
42
|
+
* Serve stats API
|
|
43
|
+
*/
|
|
44
|
+
private serveStats;
|
|
45
|
+
/**
|
|
46
|
+
* Serve jobs list
|
|
47
|
+
*/
|
|
48
|
+
private serveJobs;
|
|
49
|
+
/**
|
|
50
|
+
* Serve failed jobs
|
|
51
|
+
*/
|
|
52
|
+
private serveFailedJobs;
|
|
53
|
+
/**
|
|
54
|
+
* Handle reprocess failed job request
|
|
55
|
+
*/
|
|
56
|
+
private handleReprocessFailed;
|
|
57
|
+
/**
|
|
58
|
+
* Send stats to a specific client
|
|
59
|
+
*/
|
|
60
|
+
private sendStatsToClient;
|
|
61
|
+
/**
|
|
62
|
+
* Broadcast stats to all clients
|
|
63
|
+
*/
|
|
64
|
+
private broadcastStats;
|
|
65
|
+
/**
|
|
66
|
+
* Start periodic update interval
|
|
67
|
+
*/
|
|
68
|
+
private startUpdateInterval;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=Dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/dashboard/Dashboard.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,YAAY,CAAS;gBAEjB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe;IAkBjD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAiBrB;;OAEG;IACH,OAAO,CAAC,SAAS;IAMjB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAkC9B;;OAEG;IACH,OAAO,CAAC,UAAU;IAqBlB;;OAEG;IACH,OAAO,CAAC,SAAS;IA0BjB;;OAEG;IACH,OAAO,CAAC,eAAe;IAkBvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0C7B;;OAEG;YACW,iBAAiB;IAiC/B;;OAEG;YACW,cAAc;IAyC5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAO5B"}
|