@aitickets123654/common-kafka 1.0.40 → 1.0.41
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Producer } from 'kafkajs';
|
|
1
|
+
import { Producer, IHeaders } from 'kafkajs';
|
|
2
2
|
import { Topics } from './topics';
|
|
3
3
|
interface Event {
|
|
4
4
|
topic: Topics;
|
|
@@ -8,6 +8,6 @@ export declare abstract class Publisher<T extends Event> {
|
|
|
8
8
|
abstract topic: T['topic'];
|
|
9
9
|
protected producer: Producer;
|
|
10
10
|
protected constructor(producer: Producer);
|
|
11
|
-
publish(data: T['data']): Promise<void>;
|
|
11
|
+
publish(data: T['data'], headers?: IHeaders): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -10,13 +10,18 @@ class Publisher {
|
|
|
10
10
|
constructor(producer) {
|
|
11
11
|
this.producer = producer;
|
|
12
12
|
}
|
|
13
|
-
async publish(data) {
|
|
13
|
+
async publish(data, headers) {
|
|
14
14
|
try {
|
|
15
15
|
const schemaId = schema_ids_json_1.default[`${this.topic}-value`];
|
|
16
16
|
const encoded = await registry_1.registry.encode(schemaId, data);
|
|
17
17
|
await this.producer.send({
|
|
18
18
|
topic: this.topic,
|
|
19
|
-
messages: [
|
|
19
|
+
messages: [
|
|
20
|
+
{
|
|
21
|
+
value: encoded,
|
|
22
|
+
headers,
|
|
23
|
+
}
|
|
24
|
+
],
|
|
20
25
|
});
|
|
21
26
|
console.log(`Event published to topic '${this.topic}'`);
|
|
22
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aitickets123654/common-kafka",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "rimraf ./build",
|
|
12
12
|
"build": "npm run clean && npx tsc",
|
|
13
|
-
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
|
|
13
|
+
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish --access public"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|