@koala42/redis-highway 0.1.3 → 0.1.5

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -5
  3. package/package.json +2 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KOALA42
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # @koala42/redis-highway
2
2
 
3
- High performance Redis stream-based queue for Node.js.
3
+ High performance Redis stream-based queue for Node.js. Supports Redis single instances and Valkey single instances
4
+
5
+ ## Missing features ATM
6
+ - Better gracefull shutdown handling
7
+ - In worker process functions expose more than just data: T like job id and current status
8
+ - Option to customize/enable/disable metrics
9
+ - Enable custom logger for workers and producers instead of console.logs
10
+
11
+
12
+ ## Roadmap
13
+ - Support redis cluster, that is probably possible only for job payloads and DLQ, since the stream is only one
4
14
 
5
15
  ## Installation
6
16
 
@@ -21,7 +31,7 @@ const producer = new Producer(redis, 'my-stream');
21
31
 
22
32
  // Send job
23
33
  await producer.push(
24
- JSON.stringify({ hello: 'world' }),
34
+ JSON.stringify({ hello: 'world' }), // Message serialization is not done automatically
25
35
  ['group-A', 'group-B'] // Target specific consumer groups
26
36
  );
27
37
  ```
@@ -32,8 +42,8 @@ await producer.push(
32
42
  import { Redis } from 'ioredis';
33
43
  import { Worker } from '@koala42/redis-highway';
34
44
 
35
- class MyWorker extends Worker {
36
- async process(data: any) {
45
+ class MyWorker extends Worker<T> {
46
+ async process(data: T) {
37
47
  console.log('Processing:', data);
38
48
  // throw new Error('fail'); // Automatic retry/DLQ logic
39
49
  }
@@ -56,8 +66,59 @@ const metrics = new Metrics(redis, 'my-stream');
56
66
  const payload = await metrics.getPrometheusMetrics(['group-A']);
57
67
  ```
58
68
 
59
- ## Features
69
+ ## Usage with NestJS
70
+
71
+ ```typescript
72
+
73
+ // Producer
74
+ @Injectable()
75
+ export class EntryService {
76
+ privater readonly producer: Producer;
77
+
78
+ constructor(){
79
+ this.producer = new Producer(
80
+ new Redis(...), // Or reuse existing ioredis connection
81
+ 'my-stream'
82
+ )
83
+ }
84
+
85
+ public async sth(): Promise<void>{
86
+ await producer.push(
87
+ JSON.stringify({ hello: 'world' }), // Message serialization is not done automatically
88
+ ['group-A', 'group-B'] // Target specific consumer groups
89
+ );
90
+ }
91
+ }
92
+
60
93
 
94
+ // Processor
95
+ @Injectable()
96
+ export class ProcessorService extends Worker<T> implements OnModuleInit, OnModuleDestroy {
97
+ constructor(){
98
+ super(
99
+ new Redis(...), // or reuse existing redis conn
100
+ 'group-A',
101
+ 'my-stream',
102
+ 50 // concurrency
103
+ )
104
+ }
105
+
106
+ async onModuleInit(): Promise<void>{
107
+ await this.start()
108
+ }
109
+
110
+ onModuleDestroy(){
111
+ this.stop()
112
+ }
113
+
114
+ async process(data: T): Promise<void>{
115
+ console.log("Processing job", JSON.stringify(data))
116
+ }
117
+ }
118
+ ````
119
+
120
+ ## Features
121
+ - **Lightweight**: Uses light Lua scripts and pipelines wherever possible, making it highly concurrents for inserts and for processing as well, because of the reduced I/O load compared to BullMQ
61
122
  - **Granular Retries**: If one group fails, only that group retries.
62
123
  - **DLQ**: Dead Letter Queue support after max retries.
63
124
  - **Metrics**: Throughput, Waiting, DLQ, Prometheus export.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koala42/redis-highway",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "High performance redis queue",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -37,4 +37,4 @@
37
37
  "typescript": "^5.9.3",
38
38
  "vitest": "^4.0.16"
39
39
  }
40
- }
40
+ }