@woovi/kafka 0.1.2 → 0.1.3
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 +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,8 +22,16 @@ import {
|
|
|
22
22
|
createKafkaFromEnv('my-service');
|
|
23
23
|
|
|
24
24
|
// Create producer and publish
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let producer: WooviProducer | null = null;
|
|
26
|
+
|
|
27
|
+
export const getProducer = () => {
|
|
28
|
+
if (!producer) {
|
|
29
|
+
producer = createProducer();
|
|
30
|
+
}
|
|
31
|
+
return producer;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
await getProducer().publish({ data: { type: 'user.created', userId: '123' } });
|
|
27
35
|
|
|
28
36
|
// Create consumer and process messages
|
|
29
37
|
const consumer = createConsumer({
|