@venizia/ignis-helpers 0.0.7-0 → 0.0.7
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/dist/modules/queue/kafka/admin.d.ts +32 -0
- package/dist/modules/queue/kafka/admin.d.ts.map +1 -0
- package/dist/modules/queue/kafka/admin.js +75 -0
- package/dist/modules/queue/kafka/admin.js.map +1 -0
- package/dist/modules/queue/kafka/base.d.ts +38 -0
- package/dist/modules/queue/kafka/base.d.ts.map +1 -0
- package/dist/modules/queue/kafka/base.js +70 -0
- package/dist/modules/queue/kafka/base.js.map +1 -0
- package/dist/modules/queue/kafka/common/constants.d.ts +25 -0
- package/dist/modules/queue/kafka/common/constants.d.ts.map +1 -1
- package/dist/modules/queue/kafka/common/constants.js +38 -1
- package/dist/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/modules/queue/kafka/common/types.d.ts +76 -4
- package/dist/modules/queue/kafka/common/types.d.ts.map +1 -1
- package/dist/modules/queue/kafka/consumer.d.ts +64 -0
- package/dist/modules/queue/kafka/consumer.d.ts.map +1 -0
- package/dist/modules/queue/kafka/consumer.js +232 -0
- package/dist/modules/queue/kafka/consumer.js.map +1 -0
- package/dist/modules/queue/kafka/index.d.ts +5 -3
- package/dist/modules/queue/kafka/index.d.ts.map +1 -1
- package/dist/modules/queue/kafka/index.js +5 -3
- package/dist/modules/queue/kafka/index.js.map +1 -1
- package/dist/modules/queue/kafka/producer.d.ts +39 -0
- package/dist/modules/queue/kafka/producer.d.ts.map +1 -0
- package/dist/modules/queue/kafka/producer.js +127 -0
- package/dist/modules/queue/kafka/producer.js.map +1 -0
- package/dist/modules/queue/kafka/schema/index.d.ts +2 -0
- package/dist/modules/queue/kafka/schema/index.d.ts.map +1 -0
- package/dist/modules/queue/kafka/schema/index.js +18 -0
- package/dist/modules/queue/kafka/schema/index.js.map +1 -0
- package/dist/modules/queue/kafka/schema/registry.d.ts +29 -0
- package/dist/modules/queue/kafka/schema/registry.d.ts.map +1 -0
- package/dist/modules/queue/kafka/schema/registry.js +50 -0
- package/dist/modules/queue/kafka/schema/registry.js.map +1 -0
- package/package.json +1 -1
- package/dist/modules/queue/kafka/admin.helper.d.ts +0 -32
- package/dist/modules/queue/kafka/admin.helper.d.ts.map +0 -1
- package/dist/modules/queue/kafka/admin.helper.js +0 -59
- package/dist/modules/queue/kafka/admin.helper.js.map +0 -1
- package/dist/modules/queue/kafka/consumer.helper.d.ts +0 -55
- package/dist/modules/queue/kafka/consumer.helper.d.ts.map +0 -1
- package/dist/modules/queue/kafka/consumer.helper.js +0 -93
- package/dist/modules/queue/kafka/consumer.helper.js.map +0 -1
- package/dist/modules/queue/kafka/producer.helper.d.ts +0 -53
- package/dist/modules/queue/kafka/producer.helper.d.ts.map +0 -1
- package/dist/modules/queue/kafka/producer.helper.js +0 -85
- package/dist/modules/queue/kafka/producer.helper.js.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Admin } from '@platformatic/kafka';
|
|
2
|
+
import { BaseKafkaHelper } from './base';
|
|
3
|
+
import type { IKafkaAdminOptions } from './common/types';
|
|
4
|
+
/**
|
|
5
|
+
* KafkaAdminHelper — Wrapper around `@platformatic/kafka` Admin.
|
|
6
|
+
*
|
|
7
|
+
* Provides scoped logging, lifecycle management, and health tracking.
|
|
8
|
+
* Use `getAdmin()` to access the full Admin API directly.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const helper = KafkaAdminHelper.newInstance({
|
|
12
|
+
* bootstrapBrokers: ['127.0.0.1:29092'],
|
|
13
|
+
* clientId: 'my-admin',
|
|
14
|
+
* onBrokerConnect: ({ broker }) => console.log(`Connected to ${broker.host}:${broker.port}`),
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const admin = helper.getAdmin();
|
|
18
|
+
* await admin.createTopics({ topics: ['my-topic'], partitions: 3, replicas: 1 });
|
|
19
|
+
*
|
|
20
|
+
* helper.isHealthy(); // true when connected
|
|
21
|
+
*
|
|
22
|
+
* await helper.close();
|
|
23
|
+
*/
|
|
24
|
+
export declare class KafkaAdminHelper extends BaseKafkaHelper<Admin> {
|
|
25
|
+
constructor(opts: IKafkaAdminOptions);
|
|
26
|
+
static newInstance(opts: IKafkaAdminOptions): KafkaAdminHelper;
|
|
27
|
+
getAdmin(): Admin;
|
|
28
|
+
close(opts?: {
|
|
29
|
+
isForce?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../src/modules/queue/kafka/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,gBAAiB,SAAQ,eAAe,CAAC,KAAK,CAAC;gBAC9C,IAAI,EAAE,kBAAkB;IA6BpC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,gBAAgB;IAI9D,QAAQ,IAAI,KAAK;IAIX,KAAK,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBzD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaAdminHelper = void 0;
|
|
4
|
+
const kafka_1 = require("@platformatic/kafka");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const constants_1 = require("./common/constants");
|
|
7
|
+
/**
|
|
8
|
+
* KafkaAdminHelper — Wrapper around `@platformatic/kafka` Admin.
|
|
9
|
+
*
|
|
10
|
+
* Provides scoped logging, lifecycle management, and health tracking.
|
|
11
|
+
* Use `getAdmin()` to access the full Admin API directly.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const helper = KafkaAdminHelper.newInstance({
|
|
15
|
+
* bootstrapBrokers: ['127.0.0.1:29092'],
|
|
16
|
+
* clientId: 'my-admin',
|
|
17
|
+
* onBrokerConnect: ({ broker }) => console.log(`Connected to ${broker.host}:${broker.port}`),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const admin = helper.getAdmin();
|
|
21
|
+
* await admin.createTopics({ topics: ['my-topic'], partitions: 3, replicas: 1 });
|
|
22
|
+
*
|
|
23
|
+
* helper.isHealthy(); // true when connected
|
|
24
|
+
*
|
|
25
|
+
* await helper.close();
|
|
26
|
+
*/
|
|
27
|
+
class KafkaAdminHelper extends base_1.BaseKafkaHelper {
|
|
28
|
+
constructor(opts) {
|
|
29
|
+
super({
|
|
30
|
+
scope: KafkaAdminHelper.name,
|
|
31
|
+
identifier: opts.identifier ?? 'kafka-admin',
|
|
32
|
+
shutdownTimeout: opts.shutdownTimeout,
|
|
33
|
+
client: new kafka_1.Admin({
|
|
34
|
+
clientId: opts.clientId,
|
|
35
|
+
bootstrapBrokers: opts.bootstrapBrokers,
|
|
36
|
+
sasl: opts.sasl,
|
|
37
|
+
tls: opts.tls,
|
|
38
|
+
ssl: opts.ssl,
|
|
39
|
+
connectTimeout: opts.connectTimeout,
|
|
40
|
+
requestTimeout: opts.requestTimeout,
|
|
41
|
+
retries: opts.retries ?? constants_1.KafkaDefaults.RETRIES,
|
|
42
|
+
retryDelay: opts.retryDelay ?? constants_1.KafkaDefaults.RETRY_DELAY,
|
|
43
|
+
}),
|
|
44
|
+
onBrokerConnect: opts.onBrokerConnect,
|
|
45
|
+
onBrokerDisconnect: opts.onBrokerDisconnect,
|
|
46
|
+
});
|
|
47
|
+
this.configureBrokerEvents();
|
|
48
|
+
this.logger.info('[constructor] Kafka Admin CREATED | ClientId: %s | Brokers: %j', opts.clientId, opts.bootstrapBrokers);
|
|
49
|
+
}
|
|
50
|
+
static newInstance(opts) {
|
|
51
|
+
return new KafkaAdminHelper(opts);
|
|
52
|
+
}
|
|
53
|
+
getAdmin() {
|
|
54
|
+
return this.client;
|
|
55
|
+
}
|
|
56
|
+
async close(opts) {
|
|
57
|
+
const force = opts?.isForce ?? false;
|
|
58
|
+
if (force) {
|
|
59
|
+
await this.closeClient();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
try {
|
|
63
|
+
await this.gracefulCloseClient();
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
this.logger.warn('[close] Graceful shutdown timed out, forcing close');
|
|
67
|
+
await this.closeClient();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
this.healthStatus = constants_1.KafkaHealthStatuses.DISCONNECTED;
|
|
71
|
+
this.logger.info('[close] Admin closed | Force: %s', force);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.KafkaAdminHelper = KafkaAdminHelper;
|
|
75
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../../src/modules/queue/kafka/admin.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,iCAAyC;AACzC,kDAAwE;AAGxE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,gBAAiB,SAAQ,sBAAsB;IAC1D,YAAY,IAAwB;QAClC,KAAK,CAAC;YACJ,KAAK,EAAE,gBAAgB,CAAC,IAAI;YAC5B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,aAAa;YAC5C,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,MAAM,EAAE,IAAI,aAAK,CAAC;gBAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,IAAI,EAAE,IAAI,C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AAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CACF;AAvDD,4CAuDC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Base, BaseOptions } from '@platformatic/kafka';
|
|
2
|
+
import { BaseHelper } from '@venizia/ignis-helpers';
|
|
3
|
+
import { type TKafkaHealthStatus } from './common/constants';
|
|
4
|
+
import type { TKafkaBrokerEventCallback } from './common/types';
|
|
5
|
+
export interface IKafkaBaseOptions<TClient extends Base<BaseOptions>> {
|
|
6
|
+
scope: string;
|
|
7
|
+
identifier: string;
|
|
8
|
+
client: TClient;
|
|
9
|
+
shutdownTimeout?: number;
|
|
10
|
+
onBrokerConnect?: TKafkaBrokerEventCallback;
|
|
11
|
+
onBrokerDisconnect?: TKafkaBrokerEventCallback;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* BaseKafkaHelper — Shared health tracking and broker event wiring
|
|
15
|
+
* for all Kafka helpers (producer, consumer, admin).
|
|
16
|
+
*
|
|
17
|
+
* Generic `TClient` is the platformatic client type (Producer, Consumer, Admin).
|
|
18
|
+
* Subclasses create the client, pass it via `super({ client })`, and access it
|
|
19
|
+
* through `this.client`. Broker events are wired automatically in the constructor.
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class BaseKafkaHelper<TClient extends Base<BaseOptions>> extends BaseHelper {
|
|
22
|
+
protected readonly client: TClient;
|
|
23
|
+
protected readonly shutdownTimeout: number;
|
|
24
|
+
protected healthStatus: TKafkaHealthStatus;
|
|
25
|
+
private readonly onBrokerConnect?;
|
|
26
|
+
private readonly onBrokerDisconnect?;
|
|
27
|
+
constructor(opts: IKafkaBaseOptions<TClient>);
|
|
28
|
+
isHealthy(): boolean;
|
|
29
|
+
isReady(): boolean;
|
|
30
|
+
getHealthStatus(): TKafkaHealthStatus;
|
|
31
|
+
protected configureBrokerConnect(): void;
|
|
32
|
+
protected configureBrokerDisconnect(): void;
|
|
33
|
+
protected configureBrokerFailed(): void;
|
|
34
|
+
protected configureBrokerEvents(): void;
|
|
35
|
+
protected closeClient(): Promise<void>;
|
|
36
|
+
protected gracefulCloseClient(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/modules/queue/kafka/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAA8B,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,IAAI,CAAC,WAAW,CAAC;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,8BAAsB,eAAe,CAAC,OAAO,SAAS,IAAI,CAAC,WAAW,CAAC,CAAE,SAAQ,UAAU;IACzF,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACnC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAE3C,SAAS,CAAC,YAAY,EAAE,kBAAkB,CAA+B;IAEzE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAA4B;IAC7D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAA4B;gBAEpD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAQ5C,SAAS,IAAI,OAAO;IAIpB,OAAO,IAAI,OAAO;IAIlB,eAAe,IAAI,kBAAkB;IAIrC,SAAS,CAAC,sBAAsB;IAYhC,SAAS,CAAC,yBAAyB;IAYnC,SAAS,CAAC,qBAAqB;IAW/B,SAAS,CAAC,qBAAqB,IAAI,IAAI;IAMvC,SAAS,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,SAAS,CAAC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ/C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseKafkaHelper = void 0;
|
|
4
|
+
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
|
+
const constants_1 = require("./common/constants");
|
|
6
|
+
/**
|
|
7
|
+
* BaseKafkaHelper — Shared health tracking and broker event wiring
|
|
8
|
+
* for all Kafka helpers (producer, consumer, admin).
|
|
9
|
+
*
|
|
10
|
+
* Generic `TClient` is the platformatic client type (Producer, Consumer, Admin).
|
|
11
|
+
* Subclasses create the client, pass it via `super({ client })`, and access it
|
|
12
|
+
* through `this.client`. Broker events are wired automatically in the constructor.
|
|
13
|
+
*/
|
|
14
|
+
class BaseKafkaHelper extends ignis_helpers_1.BaseHelper {
|
|
15
|
+
constructor(opts) {
|
|
16
|
+
super({ scope: opts.scope, identifier: opts.identifier });
|
|
17
|
+
this.healthStatus = constants_1.KafkaHealthStatuses.UNKNOWN;
|
|
18
|
+
this.client = opts.client;
|
|
19
|
+
this.shutdownTimeout = opts.shutdownTimeout ?? constants_1.KafkaDefaults.SHUTDOWN_TIMEOUT;
|
|
20
|
+
this.onBrokerConnect = opts.onBrokerConnect;
|
|
21
|
+
this.onBrokerDisconnect = opts.onBrokerDisconnect;
|
|
22
|
+
}
|
|
23
|
+
isHealthy() {
|
|
24
|
+
return this.healthStatus === constants_1.KafkaHealthStatuses.CONNECTED;
|
|
25
|
+
}
|
|
26
|
+
isReady() {
|
|
27
|
+
return this.healthStatus === constants_1.KafkaHealthStatuses.CONNECTED;
|
|
28
|
+
}
|
|
29
|
+
getHealthStatus() {
|
|
30
|
+
return this.healthStatus;
|
|
31
|
+
}
|
|
32
|
+
configureBrokerConnect() {
|
|
33
|
+
this.client.on(constants_1.KafkaClientEvents.BROKER_CONNECT, (payload) => {
|
|
34
|
+
this.healthStatus = constants_1.KafkaHealthStatuses.CONNECTED;
|
|
35
|
+
this.logger.info('[configureBrokerConnect] Broker CONNECTED | Host: %s | Port: %d', payload.broker.host, payload.broker.port);
|
|
36
|
+
this.onBrokerConnect?.({ broker: payload.broker });
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
configureBrokerDisconnect() {
|
|
40
|
+
this.client.on(constants_1.KafkaClientEvents.BROKER_DISCONNECT, (payload) => {
|
|
41
|
+
this.healthStatus = constants_1.KafkaHealthStatuses.DISCONNECTED;
|
|
42
|
+
this.logger.warn('[configureBrokerDisconnect] Broker DISCONNECTED | Host: %s | Port: %d', payload.broker.host, payload.broker.port);
|
|
43
|
+
this.onBrokerDisconnect?.({ broker: payload.broker });
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
configureBrokerFailed() {
|
|
47
|
+
this.client.on(constants_1.KafkaClientEvents.BROKER_FAILED, (payload) => {
|
|
48
|
+
this.healthStatus = constants_1.KafkaHealthStatuses.DISCONNECTED;
|
|
49
|
+
this.logger.error('[configureBrokerFailed] Broker connection FAILED | Host: %s | Port: %d', payload.broker.host, payload.broker.port);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
configureBrokerEvents() {
|
|
53
|
+
this.configureBrokerConnect();
|
|
54
|
+
this.configureBrokerDisconnect();
|
|
55
|
+
this.configureBrokerFailed();
|
|
56
|
+
}
|
|
57
|
+
closeClient() {
|
|
58
|
+
return this.client.close();
|
|
59
|
+
}
|
|
60
|
+
gracefulCloseClient() {
|
|
61
|
+
return Promise.race([
|
|
62
|
+
this.closeClient(),
|
|
63
|
+
new Promise((_, reject) => {
|
|
64
|
+
setTimeout(() => reject(new Error('Shutdown timed out')), this.shutdownTimeout);
|
|
65
|
+
}),
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.BaseKafkaHelper = BaseKafkaHelper;
|
|
70
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/modules/queue/kafka/base.ts"],"names":[],"mappings":";;;AACA,0DAAoD;AACpD,kDAK4B;AAY5B;;;;;;;GAOG;AACH,MAAsB,eAAmD,SAAQ,0BAAU;IASzF,YAAY,IAAgC;QAC1C,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QANlD,iBAAY,GAAuB,+BAAmB,CAAC,OAAO,CAAC;QAOvE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,yBAAa,CAAC,gBAAgB,CAAC;QAC9E,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;IACpD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,YAAY,KAAK,+BAAmB,CAAC,SAAS,CAAC;IAC7D,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,YAAY,KAAK,+BAAmB,CAAC,SAAS,CAAC;IAC7D,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAES,sBAAsB;QAC9B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,6BAAiB,CAAC,cAAc,EAAE,CAAC,OAAmC,EAAE,EAAE;YACvF,IAAI,CAAC,YAAY,GAAG,+BAAmB,CAAC,SAAS,CAAC;YAClD,IAAI,CAAC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AmB;QAC3B,OAAO,OAAO,CAAC,IAAI,CAAC;YAClB,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;gBAC9B,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YAClF,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AAlFD,0CAkFC"}
|
|
@@ -14,6 +14,27 @@ export declare class KafkaAcks {
|
|
|
14
14
|
static isValid(ack: number): boolean;
|
|
15
15
|
}
|
|
16
16
|
export type TKafkaAcks = TConstValue<typeof KafkaAcks>;
|
|
17
|
+
export declare class KafkaHealthStatuses {
|
|
18
|
+
static readonly CONNECTED = "connected";
|
|
19
|
+
static readonly DISCONNECTED = "disconnected";
|
|
20
|
+
static readonly UNKNOWN = "unknown";
|
|
21
|
+
static readonly SCHEME_SET: Set<string>;
|
|
22
|
+
static isValid(status: string): boolean;
|
|
23
|
+
}
|
|
24
|
+
export type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;
|
|
25
|
+
export declare class KafkaClientEvents {
|
|
26
|
+
static readonly BROKER_CONNECT = "client:broker:connect";
|
|
27
|
+
static readonly BROKER_DISCONNECT = "client:broker:disconnect";
|
|
28
|
+
static readonly BROKER_FAILED = "client:broker:failed";
|
|
29
|
+
static readonly CONSUMER_GROUP_JOIN = "consumer:group:join";
|
|
30
|
+
static readonly CONSUMER_GROUP_LEAVE = "consumer:group:leave";
|
|
31
|
+
static readonly CONSUMER_GROUP_REBALANCE = "consumer:group:rebalance";
|
|
32
|
+
static readonly CONSUMER_HEARTBEAT_ERROR = "consumer:heartbeat:error";
|
|
33
|
+
static readonly CONSUMER_LAG = "consumer:lag";
|
|
34
|
+
static readonly CONSUMER_LAG_ERROR = "consumer:lag:error";
|
|
35
|
+
static readonly STREAM_DATA = "data";
|
|
36
|
+
static readonly STREAM_ERROR = "error";
|
|
37
|
+
}
|
|
17
38
|
export declare class KafkaDefaults {
|
|
18
39
|
static readonly RETRIES = 3;
|
|
19
40
|
static readonly RETRY_DELAY = 1000;
|
|
@@ -26,5 +47,9 @@ export declare class KafkaDefaults {
|
|
|
26
47
|
static readonly MIN_BYTES = 1;
|
|
27
48
|
static readonly METADATA_MAX_AGE = 300000;
|
|
28
49
|
static readonly GROUP_PROTOCOL = "classic";
|
|
50
|
+
static readonly CONSUME_MODE = "committed";
|
|
51
|
+
static readonly CONSUME_FALLBACK_MODE = "latest";
|
|
52
|
+
static readonly SHUTDOWN_TIMEOUT = 30000;
|
|
53
|
+
static readonly LAG_MONITOR_INTERVAL = 30000;
|
|
29
54
|
}
|
|
30
55
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IAEtC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA0C;IAEpE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGtC;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAMzE,qBAAa,SAAS;IACpB,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK;IACzB,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK;IAC3B,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM;IAEzB,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA+C;IAEzE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAGrC;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Q,CAAC,UAAU,SAAS;IACnC,MAAM,CAAC,QAAQ,CAAC,eAAe,SAAU;IACzC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,QAAS;IAC3C,MAAM,CAAC,QAAQ,CAAC,eAAe,QAAQ;IACvC,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK;IAC9B,MAAM,CAAC,QAAQ,CAAC,gBAAgB,UAAW;IAC3C,MAAM,CAAC,QAAQ,CAAC,cAAc,aAA8B;IAE5D,MAAM,CAAC,QAAQ,CAAC,YAAY,eAAe;IAC3C,MAAM,CAAC,QAAQ,CAAC,qBAAqB,YAAY;IAEjD,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAU;IAC1C,MAAM,CAAC,QAAQ,CAAC,oBAAoB,SAAU;CAC/C"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Group protocol enumeration
|
|
4
4
|
// -------------------------------------------------------------------------
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.KafkaDefaults = exports.KafkaAcks = exports.KafkaGroupProtocol = void 0;
|
|
6
|
+
exports.KafkaDefaults = exports.KafkaClientEvents = exports.KafkaHealthStatuses = exports.KafkaAcks = exports.KafkaGroupProtocol = void 0;
|
|
7
7
|
class KafkaGroupProtocol {
|
|
8
8
|
static { this.CLASSIC = 'classic'; }
|
|
9
9
|
static { this.CONSUMER = 'consumer'; }
|
|
@@ -29,6 +29,39 @@ exports.KafkaAcks = KafkaAcks;
|
|
|
29
29
|
// -------------------------------------------------------------------------
|
|
30
30
|
// Default values
|
|
31
31
|
// -------------------------------------------------------------------------
|
|
32
|
+
class KafkaHealthStatuses {
|
|
33
|
+
static { this.CONNECTED = 'connected'; }
|
|
34
|
+
static { this.DISCONNECTED = 'disconnected'; }
|
|
35
|
+
static { this.UNKNOWN = 'unknown'; }
|
|
36
|
+
static { this.SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]); }
|
|
37
|
+
static isValid(status) {
|
|
38
|
+
return this.SCHEME_SET.has(status);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.KafkaHealthStatuses = KafkaHealthStatuses;
|
|
42
|
+
// -------------------------------------------------------------------------
|
|
43
|
+
// Kafka events
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
45
|
+
class KafkaClientEvents {
|
|
46
|
+
// Broker events
|
|
47
|
+
static { this.BROKER_CONNECT = 'client:broker:connect'; }
|
|
48
|
+
static { this.BROKER_DISCONNECT = 'client:broker:disconnect'; }
|
|
49
|
+
static { this.BROKER_FAILED = 'client:broker:failed'; }
|
|
50
|
+
// Consumer events
|
|
51
|
+
static { this.CONSUMER_GROUP_JOIN = 'consumer:group:join'; }
|
|
52
|
+
static { this.CONSUMER_GROUP_LEAVE = 'consumer:group:leave'; }
|
|
53
|
+
static { this.CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance'; }
|
|
54
|
+
static { this.CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error'; }
|
|
55
|
+
static { this.CONSUMER_LAG = 'consumer:lag'; }
|
|
56
|
+
static { this.CONSUMER_LAG_ERROR = 'consumer:lag:error'; }
|
|
57
|
+
// Stream events
|
|
58
|
+
static { this.STREAM_DATA = 'data'; }
|
|
59
|
+
static { this.STREAM_ERROR = 'error'; }
|
|
60
|
+
}
|
|
61
|
+
exports.KafkaClientEvents = KafkaClientEvents;
|
|
62
|
+
// -------------------------------------------------------------------------
|
|
63
|
+
// Default values
|
|
64
|
+
// -------------------------------------------------------------------------
|
|
32
65
|
class KafkaDefaults {
|
|
33
66
|
// Shared
|
|
34
67
|
static { this.RETRIES = 3; }
|
|
@@ -44,6 +77,10 @@ class KafkaDefaults {
|
|
|
44
77
|
static { this.MIN_BYTES = 1; }
|
|
45
78
|
static { this.METADATA_MAX_AGE = 300_000; }
|
|
46
79
|
static { this.GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC; }
|
|
80
|
+
static { this.CONSUME_MODE = 'committed'; }
|
|
81
|
+
static { this.CONSUME_FALLBACK_MODE = 'latest'; }
|
|
82
|
+
static { this.SHUTDOWN_TIMEOUT = 30_000; }
|
|
83
|
+
static { this.LAG_MONITOR_INTERVAL = 30_000; }
|
|
47
84
|
}
|
|
48
85
|
exports.KafkaDefaults = KafkaDefaults;
|
|
49
86
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,6BAA6B;AAC7B,4EAA4E;;;AAI5E,MAAa,kBAAkB;aACb,YAAO,GAAG,SAAS,CAAC;aACpB,aAAQ,GAAG,UAAU,CAAC;aAEtB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEpE,MAAM,CAAC,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;;AARH,gDASC;AAID,4EAA4E;AAC5E,mBAAmB;AACnB,4EAA4E;AAE5E,MAAa,SAAS;aACJ,SAAI,GAAG,CAAC,CAAC,GAAC,sCAAsC;aAChD,WAAM,GAAG,CAAC,CAAC,GAAC,6BAA6B;aACzC,QAAG,GAAG,CAAC,CAAC,CAAC,GAAC,0BAA0B;aAEpC,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEzE,MAAM,CAAC,OAAO,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;;AATH,8BAUC;AAID,4EAA4E;AAC5E,iBAAiB;AACjB,4EAA4E;AAE5E,MAAa,aAAa;IACxB,SA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oBAAe,GAAG,MAAM,CAAC;aACzB,uBAAkB,GAAG,KAAK,CAAC;aAC3B,oBAAe,GAAG,IAAI,CAAC;aACvB,cAAS,GAAG,CAAC,CAAC;aACd,qBAAgB,GAAG,OAAO,CAAC;aAC3B,mBAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;aAE5C,iBAAY,GAAG,WAAW,CAAC;aAC3B,0BAAqB,GAAG,QAAQ,CAAC;aAEjC,qBAAgB,GAAG,MAAM,CAAC;aAC1B,yBAAoB,GAAG,MAAM,CAAC;;AAtBhD,sCAuBC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ValueOrPromise } from '../../../../common/types';
|
|
2
|
+
import type { Broker, CompressionAlgorithmValue, ConfluentSchemaRegistryOptions, ConnectionOptions, Consumer, Deserializers, Message, MessagesStreamFallbackModeValue, MessagesStreamModeValue, Offsets, ProduceResult, Producer, SchemaRegistry, SendOptions, Serializers } from '@platformatic/kafka';
|
|
2
3
|
import { TKafkaAcks, TKafkaGroupProtocol } from './constants';
|
|
3
4
|
export interface IKafkaConnectionOptions extends ConnectionOptions {
|
|
4
5
|
bootstrapBrokers: string[];
|
|
@@ -6,7 +7,44 @@ export interface IKafkaConnectionOptions extends ConnectionOptions {
|
|
|
6
7
|
retries?: number;
|
|
7
8
|
retryDelay?: number;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
+
export type TKafkaBrokerEventCallback = (opts: {
|
|
11
|
+
broker: Broker;
|
|
12
|
+
}) => ValueOrPromise<void>;
|
|
13
|
+
export type TKafkaMessageCallback<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string> = (opts: {
|
|
14
|
+
message: Message<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
15
|
+
}) => ValueOrPromise<void>;
|
|
16
|
+
export type TKafkaMessageDoneCallback<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string> = (opts: {
|
|
17
|
+
message: Message<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
18
|
+
}) => ValueOrPromise<void>;
|
|
19
|
+
export type TKafkaMessageErrorCallback<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string> = (opts: {
|
|
20
|
+
error: Error;
|
|
21
|
+
message?: Message<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
22
|
+
}) => ValueOrPromise<void>;
|
|
23
|
+
export type TKafkaGroupJoinCallback = (opts: {
|
|
24
|
+
groupId: string;
|
|
25
|
+
memberId: string;
|
|
26
|
+
generationId?: number;
|
|
27
|
+
}) => ValueOrPromise<void>;
|
|
28
|
+
export type TKafkaGroupLeaveCallback = (opts: {
|
|
29
|
+
groupId: string;
|
|
30
|
+
memberId: string | null;
|
|
31
|
+
}) => ValueOrPromise<void>;
|
|
32
|
+
export type TKafkaGroupRebalanceCallback = (opts: {
|
|
33
|
+
groupId: string;
|
|
34
|
+
}) => ValueOrPromise<void>;
|
|
35
|
+
export type TKafkaHeartbeatErrorCallback = (opts: {
|
|
36
|
+
error: Error;
|
|
37
|
+
groupId?: string;
|
|
38
|
+
memberId?: string | null;
|
|
39
|
+
}) => ValueOrPromise<void>;
|
|
40
|
+
export type TKafkaLagCallback = (opts: {
|
|
41
|
+
lag: Offsets;
|
|
42
|
+
}) => ValueOrPromise<void>;
|
|
43
|
+
export type TKafkaLagErrorCallback = (opts: {
|
|
44
|
+
error: Error;
|
|
45
|
+
}) => ValueOrPromise<void>;
|
|
46
|
+
export type TKafkaTransactionCallback<ResultType, KeyType, ValueType, HeaderKeyType, HeaderValueType> = (ctx: IKafkaTransactionContext<KeyType, ValueType, HeaderKeyType, HeaderValueType>) => Promise<ResultType>;
|
|
47
|
+
export interface IKafkaProducerOptions<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string> extends IKafkaConnectionOptions {
|
|
10
48
|
identifier?: string;
|
|
11
49
|
serializers?: Partial<Serializers<KeyType, ValueType, HeaderKeyType, HeaderValueType>>;
|
|
12
50
|
compression?: CompressionAlgorithmValue;
|
|
@@ -15,8 +53,12 @@ export interface IKafkaProducerOpts<KeyType = string, ValueType = string, Header
|
|
|
15
53
|
transactionalId?: string;
|
|
16
54
|
strict?: boolean;
|
|
17
55
|
autocreateTopics?: boolean;
|
|
56
|
+
shutdownTimeout?: number;
|
|
57
|
+
registry?: SchemaRegistry<unknown, unknown, KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
58
|
+
onBrokerConnect?: TKafkaBrokerEventCallback;
|
|
59
|
+
onBrokerDisconnect?: TKafkaBrokerEventCallback;
|
|
18
60
|
}
|
|
19
|
-
export interface
|
|
61
|
+
export interface IKafkaConsumerOptions<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string> extends IKafkaConnectionOptions {
|
|
20
62
|
groupId: string;
|
|
21
63
|
identifier?: string;
|
|
22
64
|
deserializers?: Partial<Deserializers<KeyType, ValueType, HeaderKeyType, HeaderValueType>>;
|
|
@@ -31,8 +73,38 @@ export interface IKafkaConsumerOpts<KeyType = string, ValueType = string, Header
|
|
|
31
73
|
metadataMaxAge?: number;
|
|
32
74
|
groupProtocol?: TKafkaGroupProtocol;
|
|
33
75
|
groupInstanceId?: string;
|
|
76
|
+
shutdownTimeout?: number;
|
|
77
|
+
registry?: SchemaRegistry<unknown, unknown, KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
78
|
+
onBrokerConnect?: TKafkaBrokerEventCallback;
|
|
79
|
+
onBrokerDisconnect?: TKafkaBrokerEventCallback;
|
|
80
|
+
onMessage?: TKafkaMessageCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
81
|
+
onMessageDone?: TKafkaMessageDoneCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
82
|
+
onMessageError?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
83
|
+
onGroupJoin?: TKafkaGroupJoinCallback;
|
|
84
|
+
onGroupLeave?: TKafkaGroupLeaveCallback;
|
|
85
|
+
onGroupRebalance?: TKafkaGroupRebalanceCallback;
|
|
86
|
+
onHeartbeatError?: TKafkaHeartbeatErrorCallback;
|
|
87
|
+
onLag?: TKafkaLagCallback;
|
|
88
|
+
onLagError?: TKafkaLagErrorCallback;
|
|
89
|
+
}
|
|
90
|
+
export interface IKafkaAdminOptions extends IKafkaConnectionOptions {
|
|
91
|
+
identifier?: string;
|
|
92
|
+
shutdownTimeout?: number;
|
|
93
|
+
onBrokerConnect?: TKafkaBrokerEventCallback;
|
|
94
|
+
onBrokerDisconnect?: TKafkaBrokerEventCallback;
|
|
95
|
+
}
|
|
96
|
+
export interface IKafkaConsumeStartOptions {
|
|
97
|
+
topics: string[];
|
|
98
|
+
mode?: MessagesStreamModeValue;
|
|
99
|
+
fallbackMode?: MessagesStreamFallbackModeValue;
|
|
100
|
+
}
|
|
101
|
+
export interface IKafkaTransactionContext<KeyType, ValueType, HeaderKeyType, HeaderValueType> {
|
|
102
|
+
transaction: Awaited<ReturnType<Producer<KeyType, ValueType, HeaderKeyType, HeaderValueType>['beginTransaction']>>;
|
|
103
|
+
send: (opts: SendOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) => Promise<ProduceResult>;
|
|
104
|
+
addConsumer: <ConsumerKeyType, ConsumerValueType, ConsumerHeaderKeyType, ConsumerHeaderValueType>(consumer: Consumer<ConsumerKeyType, ConsumerValueType, ConsumerHeaderKeyType, ConsumerHeaderValueType>) => Promise<void>;
|
|
105
|
+
addOffset: <MessageKeyType, MessageValueType, MessageHeaderKeyType, MessageHeaderValueType>(message: Message<MessageKeyType, MessageValueType, MessageHeaderKeyType, MessageHeaderValueType>) => Promise<void>;
|
|
34
106
|
}
|
|
35
|
-
export interface
|
|
107
|
+
export interface IKafkaSchemaRegistryOptions extends ConfluentSchemaRegistryOptions {
|
|
36
108
|
identifier?: string;
|
|
37
109
|
}
|
|
38
110
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EACV,MAAM,EACN,yBAAyB,EACzB,8BAA8B,EAC9B,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,OAAO,EACP,+BAA+B,EAC/B,uBAAuB,EACvB,OAAO,EACP,aAAa,EACb,QAAQ,EACR,cAAc,EACd,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD,MAAM,MAAM,yBAAyB,GAAG,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;AAE3F,MAAM,MAAM,qBAAqB,CAC/B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WAAW,EAAE,CAAC,eAAe,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,uBAAuB,EAC9F,QAAQ,EAAE,QAAQ,CAChB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,CACxB,KACE,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,SAAS,EAAE,CAAC,cAAc,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,sBAAsB,EACxF,OAAO,EAAE,OAAO,CACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,CACvB,KACE,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAMD,MAAM,WAAW,2BAA4B,SAAQ,8BAA8B;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { MessagesStream } from '@platformatic/kafka';
|
|
2
|
+
import { Consumer } from '@platformatic/kafka';
|
|
3
|
+
import { BaseKafkaHelper } from './base';
|
|
4
|
+
import type { IKafkaConsumeStartOptions, IKafkaConsumerOptions } from './common/types';
|
|
5
|
+
/**
|
|
6
|
+
* KafkaConsumerHelper — Wrapper around `@platformatic/kafka` Consumer.
|
|
7
|
+
*
|
|
8
|
+
* Provides scoped logging, lifecycle management, health tracking,
|
|
9
|
+
* graceful shutdown, message callbacks, and lag monitoring.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const helper = KafkaConsumerHelper.newInstance({
|
|
13
|
+
* bootstrapBrokers: ['127.0.0.1:29092'],
|
|
14
|
+
* clientId: 'my-consumer',
|
|
15
|
+
* groupId: 'my-consumer-group',
|
|
16
|
+
* onMessage: async ({ message }) => {
|
|
17
|
+
* console.log('Received:', message.value);
|
|
18
|
+
* await message.commit();
|
|
19
|
+
* },
|
|
20
|
+
* onMessageError: ({ error }) => console.error('Error:', error),
|
|
21
|
+
* onGroupJoin: ({ groupId, memberId }) => console.log(`Joined ${groupId}`),
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* await helper.start({ topics: ['my-topic'] });
|
|
25
|
+
*
|
|
26
|
+
* // Lag monitoring
|
|
27
|
+
* helper.startLagMonitoring({ topics: ['my-topic'] });
|
|
28
|
+
*
|
|
29
|
+
* // Health check
|
|
30
|
+
* helper.isHealthy(); // true when connected
|
|
31
|
+
*
|
|
32
|
+
* await helper.close();
|
|
33
|
+
*/
|
|
34
|
+
export declare class KafkaConsumerHelper<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string> extends BaseKafkaHelper<Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>> {
|
|
35
|
+
private stream;
|
|
36
|
+
private lagMonitoringActive;
|
|
37
|
+
private readonly onMessage?;
|
|
38
|
+
private readonly onMessageDone?;
|
|
39
|
+
private readonly onMessageError?;
|
|
40
|
+
private readonly onGroupJoin?;
|
|
41
|
+
private readonly onGroupLeave?;
|
|
42
|
+
private readonly onGroupRebalance?;
|
|
43
|
+
private readonly onHeartbeatError?;
|
|
44
|
+
private readonly onLag?;
|
|
45
|
+
private readonly onLagError?;
|
|
46
|
+
constructor(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>);
|
|
47
|
+
static newInstance<KeyType = string, ValueType = string, HeaderKeyType = string, HeaderValueType = string>(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>): KafkaConsumerHelper<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
48
|
+
getConsumer(): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>;
|
|
49
|
+
getStream(): MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null;
|
|
50
|
+
isReady(): boolean;
|
|
51
|
+
start(opts: IKafkaConsumeStartOptions): Promise<void>;
|
|
52
|
+
startLagMonitoring(opts: {
|
|
53
|
+
topics: string[];
|
|
54
|
+
interval?: number;
|
|
55
|
+
}): void;
|
|
56
|
+
stopLagMonitoring(): void;
|
|
57
|
+
protected closeClient(): Promise<void>;
|
|
58
|
+
close(opts?: {
|
|
59
|
+
isForce?: boolean;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
private closeStream;
|
|
62
|
+
protected configureBrokerEvents(): void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EAUtB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,mBAAmB,CAC9B,OAAO,GAAG,MAAM,EAChB,SAAS,GAAG,MAAM,EAClB,aAAa,GAAG,MAAM,EACtB,eAAe,GAAG,MAAM,CACxB,SAAQ,eAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;IACrF,OAAO,CAAC,MAAM,CAAmF;IACjG,OAAO,CAAC,mBAAmB,CAAS;IAGpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAKzB;IACF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAK7B;IACF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAK9B;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAA0B;IACvD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAA2B;IACzD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAA+B;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAA+B;IAGjE,OAAO,CAA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