@forklaunch/implementation-worker-kafka 1.0.21 → 1.0.22
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/lib/consumers/index.js +15 -27
- package/lib/consumers/index.mjs +11 -16
- package/lib/domain/schemas/index.js +588 -641
- package/lib/domain/schemas/index.mjs +587 -599
- package/lib/domain/types/index.js +4 -8
- package/lib/producers/index.js +8 -13
- package/lib/producers/index.mjs +4 -2
- package/package.json +5 -5
package/lib/consumers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -8,18 +8,14 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// consumers/index.ts
|
|
25
21
|
var consumers_exports = {};
|
|
@@ -29,7 +25,7 @@ __export(consumers_exports, {
|
|
|
29
25
|
module.exports = __toCommonJS(consumers_exports);
|
|
30
26
|
|
|
31
27
|
// consumers/kafkaWorker.consumer.ts
|
|
32
|
-
var import_kafkajs = require(
|
|
28
|
+
var import_kafkajs = require("kafkajs");
|
|
33
29
|
var KafkaWorkerConsumer = class {
|
|
34
30
|
kafka;
|
|
35
31
|
producer;
|
|
@@ -40,13 +36,7 @@ var KafkaWorkerConsumer = class {
|
|
|
40
36
|
processEventsFunction;
|
|
41
37
|
failureHandler;
|
|
42
38
|
openTelemetryCollector;
|
|
43
|
-
constructor(
|
|
44
|
-
queueName,
|
|
45
|
-
options,
|
|
46
|
-
processEventsFunction,
|
|
47
|
-
failureHandler,
|
|
48
|
-
openTelemetryCollector
|
|
49
|
-
) {
|
|
39
|
+
constructor(queueName, options, processEventsFunction, failureHandler, openTelemetryCollector) {
|
|
50
40
|
this.queueName = queueName;
|
|
51
41
|
this.options = options;
|
|
52
42
|
this.processEventsFunction = processEventsFunction;
|
|
@@ -147,7 +137,9 @@ var KafkaWorkerConsumer = class {
|
|
|
147
137
|
peekConsumer.run({
|
|
148
138
|
eachMessage: async ({ message }) => {
|
|
149
139
|
if (message.value && events.length < this.options.peekCount) {
|
|
150
|
-
const messageEvents = JSON.parse(
|
|
140
|
+
const messageEvents = JSON.parse(
|
|
141
|
+
message.value.toString()
|
|
142
|
+
);
|
|
151
143
|
events.push(...messageEvents);
|
|
152
144
|
if (events.length >= this.options.peekCount) {
|
|
153
145
|
resolve();
|
|
@@ -183,12 +175,9 @@ var KafkaWorkerConsumer = class {
|
|
|
183
175
|
return;
|
|
184
176
|
} catch (error) {
|
|
185
177
|
const err = error;
|
|
186
|
-
const isUnknownTopic =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
(err?.message || '').includes(
|
|
190
|
-
'This server does not host this topic-partition'
|
|
191
|
-
);
|
|
178
|
+
const isUnknownTopic = err?.code === 3 || err?.type === "UNKNOWN_TOPIC_OR_PARTITION" || (err?.message || "").includes(
|
|
179
|
+
"This server does not host this topic-partition"
|
|
180
|
+
);
|
|
192
181
|
if (!isUnknownTopic || attempt >= maxAttempts) {
|
|
193
182
|
throw error;
|
|
194
183
|
}
|
|
@@ -206,7 +195,6 @@ var KafkaWorkerConsumer = class {
|
|
|
206
195
|
}
|
|
207
196
|
};
|
|
208
197
|
// Annotate the CommonJS export names for ESM import in node:
|
|
209
|
-
0 &&
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
});
|
|
198
|
+
0 && (module.exports = {
|
|
199
|
+
KafkaWorkerConsumer
|
|
200
|
+
});
|
package/lib/consumers/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// consumers/kafkaWorker.consumer.ts
|
|
2
|
-
import { Kafka } from
|
|
2
|
+
import { Kafka } from "kafkajs";
|
|
3
3
|
var KafkaWorkerConsumer = class {
|
|
4
4
|
kafka;
|
|
5
5
|
producer;
|
|
@@ -10,13 +10,7 @@ var KafkaWorkerConsumer = class {
|
|
|
10
10
|
processEventsFunction;
|
|
11
11
|
failureHandler;
|
|
12
12
|
openTelemetryCollector;
|
|
13
|
-
constructor(
|
|
14
|
-
queueName,
|
|
15
|
-
options,
|
|
16
|
-
processEventsFunction,
|
|
17
|
-
failureHandler,
|
|
18
|
-
openTelemetryCollector
|
|
19
|
-
) {
|
|
13
|
+
constructor(queueName, options, processEventsFunction, failureHandler, openTelemetryCollector) {
|
|
20
14
|
this.queueName = queueName;
|
|
21
15
|
this.options = options;
|
|
22
16
|
this.processEventsFunction = processEventsFunction;
|
|
@@ -117,7 +111,9 @@ var KafkaWorkerConsumer = class {
|
|
|
117
111
|
peekConsumer.run({
|
|
118
112
|
eachMessage: async ({ message }) => {
|
|
119
113
|
if (message.value && events.length < this.options.peekCount) {
|
|
120
|
-
const messageEvents = JSON.parse(
|
|
114
|
+
const messageEvents = JSON.parse(
|
|
115
|
+
message.value.toString()
|
|
116
|
+
);
|
|
121
117
|
events.push(...messageEvents);
|
|
122
118
|
if (events.length >= this.options.peekCount) {
|
|
123
119
|
resolve();
|
|
@@ -153,12 +149,9 @@ var KafkaWorkerConsumer = class {
|
|
|
153
149
|
return;
|
|
154
150
|
} catch (error) {
|
|
155
151
|
const err = error;
|
|
156
|
-
const isUnknownTopic =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
(err?.message || '').includes(
|
|
160
|
-
'This server does not host this topic-partition'
|
|
161
|
-
);
|
|
152
|
+
const isUnknownTopic = err?.code === 3 || err?.type === "UNKNOWN_TOPIC_OR_PARTITION" || (err?.message || "").includes(
|
|
153
|
+
"This server does not host this topic-partition"
|
|
154
|
+
);
|
|
162
155
|
if (!isUnknownTopic || attempt >= maxAttempts) {
|
|
163
156
|
throw error;
|
|
164
157
|
}
|
|
@@ -175,4 +168,6 @@ var KafkaWorkerConsumer = class {
|
|
|
175
168
|
await this.consumer.disconnect();
|
|
176
169
|
}
|
|
177
170
|
};
|
|
178
|
-
export {
|
|
171
|
+
export {
|
|
172
|
+
KafkaWorkerConsumer
|
|
173
|
+
};
|