power-queues 2.0.17 → 2.0.19

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.
Files changed (2) hide show
  1. package/README.md +118 -225
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,151 +1,26 @@
1
- # power-queues - High‑Performance Redis Streams Queue Engine for Node.js
1
+ # power-queues
2
2
 
3
- Production‑ready, lightweight and highly scalable
4
- queue engine built directly on **Redis Streams + Lua scripts**.
5
- It is designed for real‑world distributed systems that require **high
6
- throughput**, **idempotent task execution**, **automatic recovery**, and
7
- **predictable performance under heavy load**.
3
+ ## A lightweight, scalable, and high-performance queue engine for **Node.js** built on **Redis Streams** + **Lua scripts**.
8
4
 
9
- Unlike traditional Redis‑based queues that rely on lists or heavy
10
- abstractions, power-queues focuses on **low‑level control**, **atomic
11
- operations**, and **minimal overhead**, making it ideal for highload
12
- backends, microservices, schedulers, telemetry pipelines, and data
13
- processing clusters.
5
+ The library is designed for real-world distributed systems that require high throughput, idempotent task execution, automatic recovery, and predictable performance under heavy load.
6
+
7
+ Unlike traditional Redis-based queues that rely on lists or complex abstractions, **power-queues** focuses on low-level control, atomic operations, and minimal overhead, making it ideal for high-load backends, microservices, schedulers, telemetry pipelines, and data-processing clusters.
8
+
9
+ Extends **power-redis**.
14
10
 
15
11
  <p align="center">
16
- <img src="https://img.shields.io/badge/redis-streams-red?logo=redis" />
17
- <img src="https://img.shields.io/badge/nodejs-queue-green?logo=node.js" />
18
- <img src="https://img.shields.io/badge/typescript-ready-blue?logo=typescript" />
19
- <img src="https://img.shields.io/badge/license-MIT-lightgrey" />
20
- <img src="https://img.shields.io/badge/status-production-success" />
12
+ <img src="https://img.shields.io/badge/redis-streams-red?logo=redis" />
13
+ <img src="https://img.shields.io/badge/nodejs-queue-green?logo=node.js" />
14
+ <img src="https://img.shields.io/badge/typescript-ready-blue?logo=typescript" />
15
+ <img src="https://img.shields.io/badge/license-MIT-lightgrey" />
16
+ <img src="https://img.shields.io/badge/status-production-success" />
21
17
  </p>
22
18
 
23
- ---
24
-
25
19
  ## 📚 Documentation
26
20
 
27
21
  Full documentation is available here:
28
22
  👉 **https://power-queues.docs.ihor.bielchenko.com**
29
23
 
30
- ---
31
-
32
- ## 🚀 Key Features
33
-
34
- ### **1. Ultra‑Fast Bulk XADD (Lua‑Powered)**
35
-
36
- - Adds thousands of messages per second using optimized Lua scripts.
37
- - Minimizes round‑trips to Redis.
38
- - Supports batching based on:
39
- - number of tasks
40
- - number of Redis arguments (safe upper bound)
41
- - Outperforms typical list‑based queues and generic abstractions.
42
-
43
- ---
44
-
45
- ### **2. Built‑in Idempotent Workers**
46
-
47
- Every task can carry an `idemKey`, guaranteeing **exactly‑once
48
- execution** even under: - worker crashes
49
- - network interruptions
50
- - duplicate task submissions
51
- - process restarts
52
-
53
- Idempotency includes: - Lock key
54
- - Start key
55
- - Done key
56
- - TTL‑managed execution lock
57
- - Automatic release on failure
58
- - Heartbeat mechanism
59
- - Waiting on TTL for contended executions
60
-
61
- This makes the engine ideal for: - payment processing
62
- - external API calls
63
- - high‑value jobs
64
- - distributed pipelines
65
-
66
- ---
67
-
68
- ### **3. Stuck Task Recovery (Advanced Stream Scanning)**
69
-
70
- If a worker crashes mid‑execution, power-queues automatically detects: -
71
- abandoned tasks
72
- - stalled locks
73
- - unfinished start keys
74
-
75
- The engine then recovers these tasks back to active processing safely
76
- and efficiently.
77
-
78
- ---
79
-
80
- ### **4. High‑Throughput Workers**
81
-
82
- - Batch execution support
83
- - Parallel or sequential processing mode
84
- - Configurable worker loop interval
85
- - Individual and batch‑level error hooks
86
- - Safe retry flow with per‑task attempt counters
87
-
88
- ---
89
-
90
- ### **5. Native DLQ (Dead‑Letter Queue)**
91
-
92
- When retries reach the configured limit: - the task is moved into
93
- `${stream}:dlq`
94
- - includes: payload, attempt count, job, timestamp, error text
95
- - fully JSON‑safe
96
-
97
- Perfect for monitoring or later re‑processing.
98
-
99
- ---
100
-
101
- ### **6. Zero‑Overhead Serialization**
102
-
103
- power-queues uses: - safe JSON encoding
104
- - optional "flat" key/value task format
105
- - predictable and optimized payload transformation
106
-
107
- This keeps Redis memory layout clean and eliminates overhead.
108
-
109
- ---
110
-
111
- ### **7. Complete Set of Lifecycle Hooks**
112
-
113
- You can extend any part of the execution flow:
114
-
115
- - `onSelected`
116
- - `onExecute`
117
- - `onSuccess`
118
- - `onError`
119
- - `onRetry`
120
- - `onBatchError`
121
- - `onReady`
122
-
123
- This allows full integration with: - monitoring systems
124
- - logging pipelines
125
- - external APM tools
126
- - domain logic
127
-
128
- ---
129
-
130
- ### **8. Atomic Script Loading + NOSCRIPT Recovery**
131
-
132
- Scripts are: - loaded once
133
- - cached
134
- - auto‑reloaded if Redis restarts
135
- - executed safely via SHA‑based calls
136
-
137
- Ensures resilience in failover scenarios.
138
-
139
- ---
140
-
141
- ### **9. Job Progress Tracking**
142
-
143
- Optional per‑job counters: - `job:ok` - `job:err` - `job:ready`
144
-
145
- Useful for UI dashboards and real‑time job progress visualization.
146
-
147
- ---
148
-
149
24
  ## 📦 Installation
150
25
 
151
26
  ``` bash
@@ -155,20 +30,20 @@ OR
155
30
  ```bash
156
31
  yarn add power-queues
157
32
  ```
158
- ---
159
33
 
160
- ## 🧪 Quick Start
34
+ ## 🧪 Basic usage
161
35
 
162
36
  ``` ts
163
37
  const queue = new PowerQueues({
164
- stream: "email",
165
- group: "workers",
38
+ stream: 'email',
39
+ group: 'workers',
166
40
  });
167
41
 
168
42
  await queue.loadScripts(true);
169
43
 
170
- await queue.addTasks("email", [
171
- { payload: { type: "welcome", userId: 42 } },
44
+ await queue.addTasks('email', [
45
+ { payload: { type: 'welcome', userId: 42 } },
46
+ { payload: { type: 'hello', userId: 51 } }
172
47
  ]);
173
48
  ```
174
49
 
@@ -176,15 +51,13 @@ Worker:
176
51
 
177
52
  ``` ts
178
53
  class EmailWorker extends PowerQueues {
179
- async onExecute(id, payload) {
180
- await sendEmail(payload);
181
- }
54
+ async onExecute(id, payload) {
55
+ await sendEmail(payload);
56
+ }
182
57
  }
183
58
  ```
184
59
 
185
- ---
186
-
187
- ## ⚙ power-queues vs Existing Solutions
60
+ ## ⚖️ power-queues vs Existing Solutions
188
61
 
189
62
  |Feature |power-queues |BullMQ |Bee-Queue |Custom Streams|
190
63
  |----------------------|----------------|----------- |------------|--------------|
@@ -199,108 +72,128 @@ class EmailWorker extends PowerQueues {
199
72
  |Throughput |🔥 Very high |High |Medium |Depends |
200
73
  |Overhead |Low |Medium |Low |Very high |
201
74
 
202
- ## 🛠 When to Choose power-queues
203
-
204
- Use this engine if you need:
75
+ ## 🚀 Key Features & Advantages
205
76
 
206
- ### **✔ High performance under load**
77
+ ### Ultra‑Fast Bulk XADD (Lua‑Powered)
78
+ - Adds thousands of messages per second using optimized Lua scripts.
79
+ - Minimizes round‑trips to Redis.
80
+ - Supports batching based on:
81
+ - number of tasks
82
+ - number of Redis arguments (safe upper bound)
83
+ - Outperforms typical list‑based queues and generic abstractions.
207
84
 
208
- Millions of tasks per hour? No problem.
85
+ ### Built‑in Idempotent Workers
86
+ Every task can carry an `idemKey`, guaranteeing **exactly‑once execution** even under:
87
+ - worker crashes
88
+ - network interruptions
89
+ - duplicate task submissions
90
+ - process restarts
209
91
 
210
- ### **✔ Strong idempotent guarantees**
92
+ Idempotency includes:
93
+ - Lock key
94
+ - Start key
95
+ - Done key
96
+ - TTL‑managed execution lock
97
+ - Automatic release on failure
98
+ - Heartbeat mechanism
99
+ - Waiting on TTL for contended executions
211
100
 
212
- Exactly‑once processing for critical operations.
101
+ This makes the engine ideal for:
102
+ - payment processing
103
+ - external API calls
104
+ - high‑value jobs
105
+ - distributed pipelines
213
106
 
214
- ### **✔ Low‑level control without heavy abstractions**
107
+ ### Stuck Task Recovery (Advanced Stream Scanning)
108
+ If a worker crashes mid‑execution, **power-queues** automatically detects:
109
+ - abandoned tasks
110
+ - stalled locks
111
+ - unfinished start keys
215
112
 
216
- No magic, no hidden states - everything is explicit.
113
+ The engine then recovers these tasks back to active processing safely
114
+ and efficiently.
217
115
 
218
- ### **✔ Predictable behavior in distributed environments**
116
+ ### High‑Throughput Workers
117
+ - Batch execution support
118
+ - Parallel or sequential processing mode
119
+ - Configurable worker loop interval
120
+ - Individual and batch‑level error hooks
121
+ - Safe retry flow with per‑task attempt counters
219
122
 
220
- Even with frequent worker restarts.
123
+ ### Native DLQ (Dead‑Letter Queue)
124
+ When retries reach the configured limit:
125
+ - the task is moved into `${stream}:dlq`
126
+ - includes: payload, attempt count, job, timestamp, error text
127
+ - fully JSON‑safe
221
128
 
222
- ### **✔ Productiongrade reliability**
129
+ Perfect for monitoring or later reprocessing.
223
130
 
224
- Backpressure, recovery, retries, dead-lettering - all included.
131
+ ### Zero‑Overhead Serialization
132
+ **power-queues** uses:
133
+ - safe JSON encoding
134
+ - optional "flat" key/value task format
135
+ - predictable and optimized payload transformation
225
136
 
226
- ---
137
+ This keeps Redis memory layout clean and eliminates overhead.
227
138
 
228
- ## 🏗️ Project Structure & Architecture
139
+ ### Complete Set of Lifecycle Hooks
140
+ You can extend any part of the execution flow:
141
+ - `onSelected`
142
+ - `onExecute`
143
+ - `onSuccess`
144
+ - `onError`
145
+ - `onRetry`
146
+ - `onBatchError`
147
+ - `onReady`
148
+
149
+ This allows full integration with:
150
+ - monitoring systems
151
+ - logging pipelines
152
+ - external APM tools
153
+ - domain logic
229
154
 
230
- - Redis Streams for messaging
231
- - Lua scripts for atomic operations
232
- - JavaScript/TypeScript API
233
- - Full worker lifecycle management
234
- - Configurable backpressure & contention handling
235
- - Optional joblevel progress tracking
155
+ ### Atomic Script Loading + NOSCRIPT Recovery
156
+ Scripts are:
157
+ - loaded once
158
+ - cached
159
+ - auto‑reloaded if Redis restarts
160
+ - executed safely via SHAbased calls
236
161
 
237
- ---
162
+ Ensures resilience in failover scenarios.
238
163
 
239
- ## 🧩 Extensibility
164
+ ### Job Progress Tracking
165
+ Optional per‑job counters:
166
+ - `job:ok`
167
+ - `job:err`
168
+ - `job:ready`
240
169
 
241
- power-queues is ideal for building:
170
+ Useful for UI dashboards and real‑time job progress visualization.
242
171
 
243
- - task schedulers
244
- - distributed cron engines
245
- - ETL pipelines
246
- - telemetry processors
247
- - notification workers
248
- - device monitoring systems
249
- - AI job pipelines
250
- - high-frequency background jobs
172
+ ## 🧩 Extensibility
251
173
 
252
- ---
174
+ **power-queues** is ideal for building:
175
+ - task schedulers
176
+ - distributed cron engines
177
+ - ETL pipelines
178
+ - telemetry processors
179
+ - notification workers
180
+ - device monitoring systems
181
+ - AI job pipelines
182
+ - high-frequency background jobs
253
183
 
254
184
  ## 🧱 Reliability First
255
185
 
256
186
  Every part of the engine is designed to prevent:
257
-
258
- - double execution
259
- - stuck tasks
260
- - orphan locks
261
- - lost messages
262
- - zombie workers
263
- - script desynchronization
187
+ - double execution
188
+ - stuck tasks
189
+ - orphan locks
190
+ - lost messages
191
+ - zombie workers
192
+ - script desynchronization
264
193
 
265
194
  The heartbeat + TTL strategy guarantees that no task is "lost" even in
266
195
  chaotic cluster environments.
267
196
 
268
- ---
269
-
270
- ## 🏷️ SEO‑Optimized Keywords (Non‑Spam)
271
-
272
- power-queues is relevant for:
273
-
274
- - Redis Streams queue engine
275
- - Node.js stream-based queue
276
- - idempotent task processing
277
- - high‑performance job queue for Node.js
278
- - Redis Lua queue
279
- - distributed worker engine
280
- - scalable background jobs
281
- - enterprise-grade Redis queue
282
- - microservices task runner
283
- - fault-tolerant queue for Node.js
284
-
285
- ---
286
-
287
197
  ## 📝 License
288
198
 
289
199
  MIT - free for commercial and private use.
290
-
291
- ---
292
-
293
- ## ⭐ Why This Project Exists
294
-
295
- Most Node.js queue libraries are: - too slow
296
- - too abstract
297
- - not idempotent
298
- - not safe for financial or mission‑critical workloads
299
-
300
- power-queues was built to solve real production problems where: -
301
- *duplicate tasks cost money*,
302
- - *workers are unstable*,
303
- - *tasks must survive restarts*,
304
- - *performance matters at scale*.
305
-
306
- If these things matter to you - this engine will feel like home.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-queues",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "description": "High-performance Redis Streams queue for Node.js with Lua-powered bulk XADD, idempotent workers, heartbeat locks, stuck-task recovery, retries, DLQ, and distributed processing.",
5
5
  "author": "ihor-bielchenko",
6
6
  "license": "MIT",
@@ -82,7 +82,7 @@
82
82
  ],
83
83
  "dependencies": {
84
84
  "full-utils": "^2.0.5",
85
- "power-redis": "^2.0.8",
85
+ "power-redis": "^2.0.10",
86
86
  "uuid": "^13.0.0"
87
87
  }
88
88
  }