@aitickets123654/common-kafka 1.0.34 → 1.0.35
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,6 +1,5 @@
|
|
|
1
1
|
import { Producer } from 'kafkajs';
|
|
2
2
|
import { Topics } from './topics';
|
|
3
|
-
import { registry as defaultRegistry } from './config/registry';
|
|
4
3
|
interface Event {
|
|
5
4
|
topic: Topics;
|
|
6
5
|
data: any;
|
|
@@ -8,8 +7,7 @@ interface Event {
|
|
|
8
7
|
export declare abstract class Publisher<T extends Event> {
|
|
9
8
|
abstract topic: T['topic'];
|
|
10
9
|
protected producer: Producer;
|
|
11
|
-
protected
|
|
12
|
-
protected constructor(producer: Producer, registryClient?: import("@kafkajs/confluent-schema-registry").SchemaRegistry);
|
|
10
|
+
protected constructor(producer: Producer);
|
|
13
11
|
publish(data: T['data']): Promise<void>;
|
|
14
12
|
}
|
|
15
13
|
export {};
|
|
@@ -7,14 +7,13 @@ exports.Publisher = void 0;
|
|
|
7
7
|
const registry_1 = require("./config/registry");
|
|
8
8
|
const schema_ids_json_1 = __importDefault(require("./config/schema-ids.json"));
|
|
9
9
|
class Publisher {
|
|
10
|
-
constructor(producer
|
|
10
|
+
constructor(producer) {
|
|
11
11
|
this.producer = producer;
|
|
12
|
-
this.registryClient = registryClient;
|
|
13
12
|
}
|
|
14
13
|
async publish(data) {
|
|
15
14
|
try {
|
|
16
15
|
const schemaId = schema_ids_json_1.default[`${this.topic}-value`];
|
|
17
|
-
const encoded = await
|
|
16
|
+
const encoded = await registry_1.registry.encode(schemaId, data);
|
|
18
17
|
await this.producer.send({
|
|
19
18
|
topic: this.topic,
|
|
20
19
|
messages: [{ value: encoded }],
|