@forklaunch/implementation-worker-kafka 0.6.4 → 0.7.0
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.d.mts +15 -28
- package/lib/consumers/index.d.ts +15 -28
- package/lib/consumers/index.js +11 -14
- package/lib/consumers/index.mjs +7 -3
- package/lib/domain/schemas/index.d.mts +8 -52
- package/lib/domain/schemas/index.d.ts +8 -52
- package/lib/domain/schemas/index.js +537 -579
- package/lib/domain/schemas/index.mjs +541 -543
- package/lib/domain/types/index.d.mts +6 -6
- package/lib/domain/types/index.d.ts +6 -6
- package/lib/domain/types/index.js +4 -8
- package/lib/producers/index.d.mts +7 -10
- package/lib/producers/index.d.ts +7 -10
- package/lib/producers/index.js +8 -13
- package/lib/producers/index.mjs +4 -2
- package/package.json +9 -9
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
3
|
-
WorkerEventEntity,
|
|
4
|
-
WorkerProcessFunction,
|
|
5
|
-
WorkerFailureHandler
|
|
6
|
-
} from '@forklaunch/interfaces-worker/types';
|
|
2
|
+
import { WorkerEventEntity, WorkerProcessFunction, WorkerFailureHandler } from '@forklaunch/interfaces-worker/types';
|
|
7
3
|
import { KafkaWorkerOptions } from '../domain/types/index.mjs';
|
|
8
4
|
|
|
9
|
-
declare class KafkaWorkerConsumer<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
queueName: string,
|
|
24
|
-
options: Options,
|
|
25
|
-
processEventsFunction: WorkerProcessFunction<EventEntity>,
|
|
26
|
-
failureHandler: WorkerFailureHandler<EventEntity>
|
|
27
|
-
);
|
|
28
|
-
private setupConsumer;
|
|
29
|
-
peekEvents(): Promise<EventEntity[]>;
|
|
30
|
-
start(): Promise<void>;
|
|
31
|
-
close(): Promise<void>;
|
|
5
|
+
declare class KafkaWorkerConsumer<EventEntity extends WorkerEventEntity, Options extends KafkaWorkerOptions> implements WorkerConsumer<EventEntity> {
|
|
6
|
+
private kafka;
|
|
7
|
+
private producer;
|
|
8
|
+
private consumer;
|
|
9
|
+
private processedMessages;
|
|
10
|
+
protected readonly queueName: string;
|
|
11
|
+
protected readonly options: Options;
|
|
12
|
+
protected readonly processEventsFunction: WorkerProcessFunction<EventEntity>;
|
|
13
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
14
|
+
constructor(queueName: string, options: Options, processEventsFunction: WorkerProcessFunction<EventEntity>, failureHandler: WorkerFailureHandler<EventEntity>);
|
|
15
|
+
private setupConsumer;
|
|
16
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
close(): Promise<void>;
|
|
32
19
|
}
|
|
33
20
|
|
|
34
21
|
export { KafkaWorkerConsumer };
|
package/lib/consumers/index.d.ts
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
3
|
-
WorkerEventEntity,
|
|
4
|
-
WorkerProcessFunction,
|
|
5
|
-
WorkerFailureHandler
|
|
6
|
-
} from '@forklaunch/interfaces-worker/types';
|
|
2
|
+
import { WorkerEventEntity, WorkerProcessFunction, WorkerFailureHandler } from '@forklaunch/interfaces-worker/types';
|
|
7
3
|
import { KafkaWorkerOptions } from '../domain/types/index.js';
|
|
8
4
|
|
|
9
|
-
declare class KafkaWorkerConsumer<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
queueName: string,
|
|
24
|
-
options: Options,
|
|
25
|
-
processEventsFunction: WorkerProcessFunction<EventEntity>,
|
|
26
|
-
failureHandler: WorkerFailureHandler<EventEntity>
|
|
27
|
-
);
|
|
28
|
-
private setupConsumer;
|
|
29
|
-
peekEvents(): Promise<EventEntity[]>;
|
|
30
|
-
start(): Promise<void>;
|
|
31
|
-
close(): Promise<void>;
|
|
5
|
+
declare class KafkaWorkerConsumer<EventEntity extends WorkerEventEntity, Options extends KafkaWorkerOptions> implements WorkerConsumer<EventEntity> {
|
|
6
|
+
private kafka;
|
|
7
|
+
private producer;
|
|
8
|
+
private consumer;
|
|
9
|
+
private processedMessages;
|
|
10
|
+
protected readonly queueName: string;
|
|
11
|
+
protected readonly options: Options;
|
|
12
|
+
protected readonly processEventsFunction: WorkerProcessFunction<EventEntity>;
|
|
13
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
14
|
+
constructor(queueName: string, options: Options, processEventsFunction: WorkerProcessFunction<EventEntity>, failureHandler: WorkerFailureHandler<EventEntity>);
|
|
15
|
+
private setupConsumer;
|
|
16
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
close(): Promise<void>;
|
|
32
19
|
}
|
|
33
20
|
|
|
34
21
|
export { KafkaWorkerConsumer };
|
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;
|
|
@@ -139,7 +135,9 @@ var KafkaWorkerConsumer = class {
|
|
|
139
135
|
peekConsumer.run({
|
|
140
136
|
eachMessage: async ({ message }) => {
|
|
141
137
|
if (message.value && events.length < this.options.peekCount) {
|
|
142
|
-
const messageEvents = JSON.parse(
|
|
138
|
+
const messageEvents = JSON.parse(
|
|
139
|
+
message.value.toString()
|
|
140
|
+
);
|
|
143
141
|
events.push(...messageEvents);
|
|
144
142
|
if (events.length >= this.options.peekCount) {
|
|
145
143
|
resolve();
|
|
@@ -174,7 +172,6 @@ var KafkaWorkerConsumer = class {
|
|
|
174
172
|
}
|
|
175
173
|
};
|
|
176
174
|
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
-
0 &&
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
175
|
+
0 && (module.exports = {
|
|
176
|
+
KafkaWorkerConsumer
|
|
177
|
+
});
|
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;
|
|
@@ -109,7 +109,9 @@ var KafkaWorkerConsumer = class {
|
|
|
109
109
|
peekConsumer.run({
|
|
110
110
|
eachMessage: async ({ message }) => {
|
|
111
111
|
if (message.value && events.length < this.options.peekCount) {
|
|
112
|
-
const messageEvents = JSON.parse(
|
|
112
|
+
const messageEvents = JSON.parse(
|
|
113
|
+
message.value.toString()
|
|
114
|
+
);
|
|
113
115
|
events.push(...messageEvents);
|
|
114
116
|
if (events.length >= this.options.peekCount) {
|
|
115
117
|
resolve();
|
|
@@ -143,4 +145,6 @@ var KafkaWorkerConsumer = class {
|
|
|
143
145
|
await this.consumer.disconnect();
|
|
144
146
|
}
|
|
145
147
|
};
|
|
146
|
-
export {
|
|
148
|
+
export {
|
|
149
|
+
KafkaWorkerConsumer
|
|
150
|
+
};
|
|
@@ -3,66 +3,22 @@ import * as zod_v3 from 'zod/v3';
|
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
5
|
|
|
6
|
-
declare const KafkaWorkerSchemas: <
|
|
7
|
-
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
-
>(
|
|
9
|
-
options: Record<string, unknown> & {
|
|
6
|
+
declare const KafkaWorkerSchemas: <SchemaValidator extends _forklaunch_validator.AnySchemaValidator>(options: Record<string, unknown> & {
|
|
10
7
|
validator: SchemaValidator;
|
|
11
|
-
|
|
12
|
-
) => _forklaunch_internal.SchemasByValidator<
|
|
13
|
-
SchemaValidator,
|
|
14
|
-
(options: Record<string, unknown>) => {
|
|
8
|
+
}) => _forklaunch_internal.SchemasByValidator<SchemaValidator, (options: Record<string, unknown>) => {
|
|
15
9
|
brokers: _sinclair_typebox.TArray<_sinclair_typebox.TString>;
|
|
16
10
|
clientId: _sinclair_typebox.TString;
|
|
17
11
|
groupId: _sinclair_typebox.TString;
|
|
18
|
-
retries: _sinclair_typebox.TTransform<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_sinclair_typebox.TBoolean,
|
|
24
|
-
_sinclair_typebox.TNull,
|
|
25
|
-
_sinclair_typebox.TBigInt,
|
|
26
|
-
_sinclair_typebox.TDate
|
|
27
|
-
]
|
|
28
|
-
>,
|
|
29
|
-
number
|
|
30
|
-
>;
|
|
31
|
-
interval: _sinclair_typebox.TTransform<
|
|
32
|
-
_sinclair_typebox.TUnion<
|
|
33
|
-
[
|
|
34
|
-
_sinclair_typebox.TNumber,
|
|
35
|
-
_sinclair_typebox.TString,
|
|
36
|
-
_sinclair_typebox.TBoolean,
|
|
37
|
-
_sinclair_typebox.TNull,
|
|
38
|
-
_sinclair_typebox.TBigInt,
|
|
39
|
-
_sinclair_typebox.TDate
|
|
40
|
-
]
|
|
41
|
-
>,
|
|
42
|
-
number
|
|
43
|
-
>;
|
|
44
|
-
peekCount: _sinclair_typebox.TTransform<
|
|
45
|
-
_sinclair_typebox.TUnion<
|
|
46
|
-
[
|
|
47
|
-
_sinclair_typebox.TNumber,
|
|
48
|
-
_sinclair_typebox.TString,
|
|
49
|
-
_sinclair_typebox.TBoolean,
|
|
50
|
-
_sinclair_typebox.TNull,
|
|
51
|
-
_sinclair_typebox.TBigInt,
|
|
52
|
-
_sinclair_typebox.TDate
|
|
53
|
-
]
|
|
54
|
-
>,
|
|
55
|
-
number
|
|
56
|
-
>;
|
|
57
|
-
},
|
|
58
|
-
(options: Record<string, unknown>) => {
|
|
59
|
-
brokers: zod_v3.ZodArray<zod_v3.ZodString, 'many'>;
|
|
12
|
+
retries: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
13
|
+
interval: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
14
|
+
peekCount: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
15
|
+
}, (options: Record<string, unknown>) => {
|
|
16
|
+
brokers: zod_v3.ZodArray<zod_v3.ZodString, "many">;
|
|
60
17
|
clientId: zod_v3.ZodString;
|
|
61
18
|
groupId: zod_v3.ZodString;
|
|
62
19
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
63
20
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
64
21
|
peekCount: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
65
|
-
|
|
66
|
-
>;
|
|
22
|
+
}>;
|
|
67
23
|
|
|
68
24
|
export { KafkaWorkerSchemas };
|
|
@@ -3,66 +3,22 @@ import * as zod_v3 from 'zod/v3';
|
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
5
|
|
|
6
|
-
declare const KafkaWorkerSchemas: <
|
|
7
|
-
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
-
>(
|
|
9
|
-
options: Record<string, unknown> & {
|
|
6
|
+
declare const KafkaWorkerSchemas: <SchemaValidator extends _forklaunch_validator.AnySchemaValidator>(options: Record<string, unknown> & {
|
|
10
7
|
validator: SchemaValidator;
|
|
11
|
-
|
|
12
|
-
) => _forklaunch_internal.SchemasByValidator<
|
|
13
|
-
SchemaValidator,
|
|
14
|
-
(options: Record<string, unknown>) => {
|
|
8
|
+
}) => _forklaunch_internal.SchemasByValidator<SchemaValidator, (options: Record<string, unknown>) => {
|
|
15
9
|
brokers: _sinclair_typebox.TArray<_sinclair_typebox.TString>;
|
|
16
10
|
clientId: _sinclair_typebox.TString;
|
|
17
11
|
groupId: _sinclair_typebox.TString;
|
|
18
|
-
retries: _sinclair_typebox.TTransform<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_sinclair_typebox.TBoolean,
|
|
24
|
-
_sinclair_typebox.TNull,
|
|
25
|
-
_sinclair_typebox.TBigInt,
|
|
26
|
-
_sinclair_typebox.TDate
|
|
27
|
-
]
|
|
28
|
-
>,
|
|
29
|
-
number
|
|
30
|
-
>;
|
|
31
|
-
interval: _sinclair_typebox.TTransform<
|
|
32
|
-
_sinclair_typebox.TUnion<
|
|
33
|
-
[
|
|
34
|
-
_sinclair_typebox.TNumber,
|
|
35
|
-
_sinclair_typebox.TString,
|
|
36
|
-
_sinclair_typebox.TBoolean,
|
|
37
|
-
_sinclair_typebox.TNull,
|
|
38
|
-
_sinclair_typebox.TBigInt,
|
|
39
|
-
_sinclair_typebox.TDate
|
|
40
|
-
]
|
|
41
|
-
>,
|
|
42
|
-
number
|
|
43
|
-
>;
|
|
44
|
-
peekCount: _sinclair_typebox.TTransform<
|
|
45
|
-
_sinclair_typebox.TUnion<
|
|
46
|
-
[
|
|
47
|
-
_sinclair_typebox.TNumber,
|
|
48
|
-
_sinclair_typebox.TString,
|
|
49
|
-
_sinclair_typebox.TBoolean,
|
|
50
|
-
_sinclair_typebox.TNull,
|
|
51
|
-
_sinclair_typebox.TBigInt,
|
|
52
|
-
_sinclair_typebox.TDate
|
|
53
|
-
]
|
|
54
|
-
>,
|
|
55
|
-
number
|
|
56
|
-
>;
|
|
57
|
-
},
|
|
58
|
-
(options: Record<string, unknown>) => {
|
|
59
|
-
brokers: zod_v3.ZodArray<zod_v3.ZodString, 'many'>;
|
|
12
|
+
retries: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
13
|
+
interval: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
14
|
+
peekCount: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
15
|
+
}, (options: Record<string, unknown>) => {
|
|
16
|
+
brokers: zod_v3.ZodArray<zod_v3.ZodString, "many">;
|
|
60
17
|
clientId: zod_v3.ZodString;
|
|
61
18
|
groupId: zod_v3.ZodString;
|
|
62
19
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
63
20
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
64
21
|
peekCount: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
65
|
-
|
|
66
|
-
>;
|
|
22
|
+
}>;
|
|
67
23
|
|
|
68
24
|
export { KafkaWorkerSchemas };
|