@forklaunch/implementation-worker-kafka 1.0.20 → 1.0.21

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