redis-kafka 0.0.1 → 0.0.2
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 +49 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# redis-kafka
|
|
2
|
+
|
|
3
|
+
Lightweight event bus for Node.js microservices powered by Redis Streams.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install redis-kafka ioredis
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { EventBus } from "redis-kafka";
|
|
15
|
+
|
|
16
|
+
const bus = new EventBus({ url: "redis://localhost:6379" });
|
|
17
|
+
|
|
18
|
+
const auth = await bus.group("auth-service");
|
|
19
|
+
const mail = await bus.group("mail-service");
|
|
20
|
+
const profile = await bus.group("profile-service");
|
|
21
|
+
|
|
22
|
+
// Publish
|
|
23
|
+
await auth.publish("user.registered", { userId: "123", email: "john@test.com" });
|
|
24
|
+
|
|
25
|
+
// Subscribe (independent fanout per group)
|
|
26
|
+
await mail.subscribe("user.registered", async (payload) => {
|
|
27
|
+
console.log("send mail to", payload.email);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await profile.subscribe("user.registered", async (payload) => {
|
|
31
|
+
console.log("create profile for", payload.userId);
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## How it works
|
|
36
|
+
|
|
37
|
+
- Built on **Redis Streams** — no Kafka, no Zookeeper, no extra infra
|
|
38
|
+
- Each `bus.group()` creates an independent **Redis Consumer Group**
|
|
39
|
+
- All groups receive every published event (Kafka-like fanout)
|
|
40
|
+
- Groups are created automatically — no manual setup needed
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
- Node.js >= 18
|
|
45
|
+
- Redis >= 6.2
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|