@venizia/ignis-helpers 0.4.2 → 0.4.3
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/cjs/common/types/field-mapping.d.ts +13 -1
- package/dist/cjs/common/types/field-mapping.d.ts.map +1 -1
- package/dist/cjs/common/types/field-mapping.js +20 -0
- package/dist/cjs/common/types/field-mapping.js.map +1 -1
- package/dist/cjs/core.d.ts +2 -1
- package/dist/cjs/core.d.ts.map +1 -1
- package/dist/cjs/core.js +6 -1
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.d.ts +2 -2
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.d.ts.map +1 -1
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.js +3 -1
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
- package/dist/cjs/modules/crypto/algorithms/aes.constants.d.ts +11 -0
- package/dist/cjs/modules/crypto/algorithms/aes.constants.d.ts.map +1 -0
- package/dist/cjs/modules/crypto/algorithms/aes.constants.js +14 -0
- package/dist/cjs/modules/crypto/algorithms/aes.constants.js.map +1 -0
- package/dist/cjs/modules/error/index.d.ts +1 -1
- package/dist/cjs/modules/error/index.d.ts.map +1 -1
- package/dist/cjs/modules/error/index.js +2 -1
- package/dist/cjs/modules/error/index.js.map +1 -1
- package/dist/cjs/modules/logger/hf/common/types.d.ts +3 -1
- package/dist/cjs/modules/logger/hf/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/logger/hf/common/types.js.map +1 -1
- package/dist/cjs/modules/logger/pino/common/constants.d.ts +10 -1
- package/dist/cjs/modules/logger/pino/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/logger/pino/common/constants.js +11 -1
- package/dist/cjs/modules/logger/pino/common/constants.js.map +1 -1
- package/dist/cjs/modules/logger/pino/destination.d.ts.map +1 -1
- package/dist/cjs/modules/logger/pino/destination.js +4 -3
- package/dist/cjs/modules/logger/pino/destination.js.map +1 -1
- package/dist/cjs/modules/network/http-request/common/constants.d.ts +11 -0
- package/dist/cjs/modules/network/http-request/common/constants.d.ts.map +1 -0
- package/dist/cjs/modules/network/http-request/common/constants.js +14 -0
- package/dist/cjs/modules/network/http-request/common/constants.js.map +1 -0
- package/dist/cjs/modules/network/http-request/common/index.d.ts +1 -0
- package/dist/cjs/modules/network/http-request/common/index.d.ts.map +1 -1
- package/dist/cjs/modules/network/http-request/common/index.js +1 -0
- package/dist/cjs/modules/network/http-request/common/index.js.map +1 -1
- package/dist/cjs/modules/network/http-request/common/types.d.ts +1 -1
- package/dist/cjs/modules/network/http-request/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/network/http-request/common/types.js.map +1 -1
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.d.ts +13 -2
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +1 -1
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.js +23 -6
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/cjs/modules/queue/common/constants.d.ts +11 -0
- package/dist/cjs/modules/queue/common/constants.d.ts.map +1 -0
- package/dist/cjs/modules/queue/common/constants.js +14 -0
- package/dist/cjs/modules/queue/common/constants.js.map +1 -0
- package/dist/cjs/modules/queue/common/index.d.ts +1 -0
- package/dist/cjs/modules/queue/common/index.d.ts.map +1 -1
- package/dist/cjs/modules/queue/common/index.js +1 -0
- package/dist/cjs/modules/queue/common/index.js.map +1 -1
- package/dist/cjs/modules/queue/common/types.d.ts +1 -1
- package/dist/cjs/modules/queue/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/queue/common/types.js.map +1 -1
- package/dist/cjs/modules/queue/kafka/common/constants.d.ts +9 -0
- package/dist/cjs/modules/queue/kafka/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/queue/kafka/common/constants.js +11 -1
- package/dist/cjs/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/cjs/modules/queue/kafka/consumer.d.ts +2 -1
- package/dist/cjs/modules/queue/kafka/consumer.d.ts.map +1 -1
- package/dist/cjs/modules/queue/kafka/consumer.js +2 -2
- package/dist/cjs/modules/queue/kafka/consumer.js.map +1 -1
- package/dist/cjs/modules/temporal/common/constants.d.ts +21 -0
- package/dist/cjs/modules/temporal/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/common/constants.js +22 -1
- package/dist/cjs/modules/temporal/common/constants.js.map +1 -1
- package/dist/cjs/modules/temporal/locale/locale.d.ts +4 -3
- package/dist/cjs/modules/temporal/locale/locale.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/locale/locale.js +2 -1
- package/dist/cjs/modules/temporal/locale/locale.js.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/constants.d.ts +43 -0
- package/dist/cjs/modules/temporal/pattern/common/constants.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/constants.js +74 -0
- package/dist/cjs/modules/temporal/pattern/common/constants.js.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.d.ts +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/index.js +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.js.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/types.d.ts +2 -11
- package/dist/cjs/modules/temporal/pattern/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/types.js.map +1 -1
- package/dist/cjs/modules/temporal/pattern/tokens.d.ts +2 -1
- package/dist/cjs/modules/temporal/pattern/tokens.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/pattern/tokens.js +2 -14
- package/dist/cjs/modules/temporal/pattern/tokens.js.map +1 -1
- package/dist/cjs/utilities/request.utility.d.ts +21 -2
- package/dist/cjs/utilities/request.utility.d.ts.map +1 -1
- package/dist/cjs/utilities/request.utility.js +25 -5
- package/dist/cjs/utilities/request.utility.js.map +1 -1
- package/dist/esm/common/types/field-mapping.d.ts +13 -1
- package/dist/esm/common/types/field-mapping.d.ts.map +1 -1
- package/dist/esm/common/types/field-mapping.js +18 -1
- package/dist/esm/common/types/field-mapping.js.map +1 -1
- package/dist/esm/core.d.ts +2 -1
- package/dist/esm/core.d.ts.map +1 -1
- package/dist/esm/core.js +4 -0
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts +2 -2
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +2 -0
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts +11 -0
- package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts.map +1 -0
- package/dist/esm/modules/crypto/algorithms/aes.constants.js +10 -0
- package/dist/esm/modules/crypto/algorithms/aes.constants.js.map +1 -0
- package/dist/esm/modules/error/index.d.ts +1 -1
- package/dist/esm/modules/error/index.d.ts.map +1 -1
- package/dist/esm/modules/error/index.js +1 -1
- package/dist/esm/modules/error/index.js.map +1 -1
- package/dist/esm/modules/logger/hf/common/types.d.ts +3 -1
- package/dist/esm/modules/logger/hf/common/types.d.ts.map +1 -1
- package/dist/esm/modules/logger/hf/common/types.js.map +1 -1
- package/dist/esm/modules/logger/pino/common/constants.d.ts +10 -1
- package/dist/esm/modules/logger/pino/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/logger/pino/common/constants.js +9 -0
- package/dist/esm/modules/logger/pino/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
- package/dist/esm/modules/logger/pino/destination.js +4 -3
- package/dist/esm/modules/logger/pino/destination.js.map +1 -1
- package/dist/esm/modules/network/http-request/common/constants.d.ts +11 -0
- package/dist/esm/modules/network/http-request/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/network/http-request/common/constants.js +10 -0
- package/dist/esm/modules/network/http-request/common/constants.js.map +1 -0
- package/dist/esm/modules/network/http-request/common/index.d.ts +1 -0
- package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/common/index.js +1 -0
- package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
- package/dist/esm/modules/network/http-request/common/types.d.ts +1 -1
- package/dist/esm/modules/network/http-request/common/types.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/common/types.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +13 -2
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +21 -5
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/queue/common/constants.d.ts +11 -0
- package/dist/esm/modules/queue/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/queue/common/constants.js +10 -0
- package/dist/esm/modules/queue/common/constants.js.map +1 -0
- package/dist/esm/modules/queue/common/index.d.ts +1 -0
- package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
- package/dist/esm/modules/queue/common/index.js +1 -0
- package/dist/esm/modules/queue/common/index.js.map +1 -1
- package/dist/esm/modules/queue/common/types.d.ts +1 -1
- package/dist/esm/modules/queue/common/types.d.ts.map +1 -1
- package/dist/esm/modules/queue/common/types.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/constants.d.ts +9 -0
- package/dist/esm/modules/queue/kafka/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/common/constants.js +9 -0
- package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/esm/modules/queue/kafka/consumer.d.ts +2 -1
- package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/consumer.js +3 -3
- package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
- package/dist/esm/modules/temporal/common/constants.d.ts +21 -0
- package/dist/esm/modules/temporal/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/temporal/common/constants.js +19 -0
- package/dist/esm/modules/temporal/common/constants.js.map +1 -1
- package/dist/esm/modules/temporal/locale/locale.d.ts +4 -3
- package/dist/esm/modules/temporal/locale/locale.d.ts.map +1 -1
- package/dist/esm/modules/temporal/locale/locale.js +2 -1
- package/dist/esm/modules/temporal/locale/locale.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/constants.d.ts +43 -0
- package/dist/esm/modules/temporal/pattern/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/constants.js +70 -0
- package/dist/esm/modules/temporal/pattern/common/constants.js.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.d.ts +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/index.js +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/types.d.ts +2 -11
- package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/types.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/tokens.d.ts +2 -1
- package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +1 -1
- package/dist/esm/modules/temporal/pattern/tokens.js +2 -14
- package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -1
- package/dist/esm/utilities/request.utility.d.ts +21 -2
- package/dist/esm/utilities/request.utility.d.ts.map +1 -1
- package/dist/esm/utilities/request.utility.js +22 -4
- package/dist/esm/utilities/request.utility.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import type { TConstValue } from '../../../common/types';
|
|
1
2
|
import { type ValueOrPromise } from '../../../common/types';
|
|
2
3
|
import { BaseHelper } from '../../base';
|
|
3
4
|
import { type ListenOptions, type ServerOpts, type Socket as SocketClient, type Server as SocketServer } from 'node:net';
|
|
5
|
+
/** Where a TCP client is in the authentication handshake. */
|
|
6
|
+
export declare class TcpClientStates {
|
|
7
|
+
static readonly UNAUTHORIZED = "unauthorized";
|
|
8
|
+
static readonly AUTHENTICATING = "authenticating";
|
|
9
|
+
static readonly AUTHENTICATED = "authenticated";
|
|
10
|
+
static readonly SCHEME_SET: Set<string>;
|
|
11
|
+
static isValid(value: string): boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Valid TCP client state values. */
|
|
14
|
+
export type TTcpClientState = TConstValue<typeof TcpClientStates>;
|
|
4
15
|
export interface ITcpSocketClient<SocketClientType> {
|
|
5
16
|
id: string;
|
|
6
17
|
socket: SocketClientType;
|
|
7
|
-
state:
|
|
18
|
+
state: TTcpClientState;
|
|
8
19
|
subscriptions: Set<string>;
|
|
9
20
|
storage: {
|
|
10
21
|
connectedAt: Date;
|
|
@@ -112,7 +123,7 @@ export declare class BaseNetworkTcpServer<SocketServerOptions extends ServerOpts
|
|
|
112
123
|
shutdown(): Promise<void>;
|
|
113
124
|
doAuthenticate(opts: {
|
|
114
125
|
id: string;
|
|
115
|
-
state:
|
|
126
|
+
state: TTcpClientState;
|
|
116
127
|
}): void;
|
|
117
128
|
emit(opts: {
|
|
118
129
|
clientId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-tcp-server.helper.d.ts","sourceRoot":"","sources":["../../../../../src/modules/network/tcp-socket/base-tcp-server.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,MAAM,IAAI,YAAY,EAC3B,KAAK,MAAM,IAAI,YAAY,EAC5B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,gBAAgB,CAAC,gBAAgB;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"base-tcp-server.helper.d.ts","sourceRoot":"","sources":["../../../../../src/modules/network/tcp-socket/base-tcp-server.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,MAAM,IAAI,YAAY,EAC3B,KAAK,MAAM,IAAI,YAAY,EAC5B,MAAM,UAAU,CAAC;AAElB,6DAA6D;AAC7D,qBAAa,eAAe;IAC1B,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,cAAc,oBAAoB;IAClD,MAAM,CAAC,QAAQ,CAAC,aAAa,mBAAmB;IAEhD,MAAM,CAAC,QAAQ,CAAC,UAAU,cAIvB;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,qCAAqC;AACrC,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,eAAe,CAAC,CAAC;AAElE,MAAM,WAAW,gBAAgB,CAAC,gBAAgB;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,eAAe,CAAC;IACvB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,EAAE;QACP,WAAW,EAAE,IAAI,CAAC;QAClB,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;QAC7B,mBAAmB,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;QAC3D,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KACvC,CAAC;CACH;AAED,M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E,EAAE,EAAE,MAAM,CAAA;KAAE;IAI9B,SAAS;IAIT,0LAA0L;IACpL,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAkC/B,cAAc,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,eAAe,CAAA;KAAE;IAgC3D,IAAI,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;CA4B1D"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseNetworkTcpServer = void 0;
|
|
3
|
+
exports.BaseNetworkTcpServer = exports.TcpClientStates = void 0;
|
|
4
4
|
const base_1 = require("../../base");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
6
|
const parse_utility_1 = require("../../../utilities/parse.utility");
|
|
7
7
|
const promise_utility_1 = require("../../../utilities/promise.utility");
|
|
8
|
+
/** Where a TCP client is in the authentication handshake. */
|
|
9
|
+
class TcpClientStates {
|
|
10
|
+
static { this.UNAUTHORIZED = 'unauthorized'; }
|
|
11
|
+
static { this.AUTHENTICATING = 'authenticating'; }
|
|
12
|
+
static { this.AUTHENTICATED = 'authenticated'; }
|
|
13
|
+
static { this.SCHEME_SET = new Set([
|
|
14
|
+
this.UNAUTHORIZED,
|
|
15
|
+
this.AUTHENTICATING,
|
|
16
|
+
this.AUTHENTICATED,
|
|
17
|
+
]); }
|
|
18
|
+
static isValid(value) {
|
|
19
|
+
return this.SCHEME_SET.has(value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.TcpClientStates = TcpClientStates;
|
|
8
23
|
class BaseNetworkTcpServer extends base_1.BaseHelper {
|
|
9
24
|
constructor(opts) {
|
|
10
25
|
super({
|
|
@@ -124,7 +139,9 @@ class BaseNetworkTcpServer extends base_1.BaseHelper {
|
|
|
124
139
|
this.clients[id] = {
|
|
125
140
|
id,
|
|
126
141
|
socket,
|
|
127
|
-
state: this.authenticateOptions.required
|
|
142
|
+
state: this.authenticateOptions.required
|
|
143
|
+
? TcpClientStates.UNAUTHORIZED
|
|
144
|
+
: TcpClientStates.AUTHENTICATED,
|
|
128
145
|
subscriptions: new Set([]),
|
|
129
146
|
storage: {
|
|
130
147
|
connectedAt: new Date(),
|
|
@@ -149,7 +166,7 @@ class BaseNetworkTcpServer extends base_1.BaseHelper {
|
|
|
149
166
|
return;
|
|
150
167
|
}
|
|
151
168
|
client.storage.authenticateTimeout = null;
|
|
152
|
-
if (client.state ===
|
|
169
|
+
if (client.state === TcpClientStates.AUTHENTICATED) {
|
|
153
170
|
return;
|
|
154
171
|
}
|
|
155
172
|
this.emit({ clientId: id, payload: 'Unauthorized Client' });
|
|
@@ -208,12 +225,12 @@ class BaseNetworkTcpServer extends base_1.BaseHelper {
|
|
|
208
225
|
}
|
|
209
226
|
client.state = state;
|
|
210
227
|
switch (state) {
|
|
211
|
-
case
|
|
212
|
-
case
|
|
228
|
+
case TcpClientStates.UNAUTHORIZED:
|
|
229
|
+
case TcpClientStates.AUTHENTICATING: {
|
|
213
230
|
client.storage.authenticatedAt = null;
|
|
214
231
|
break;
|
|
215
232
|
}
|
|
216
|
-
case
|
|
233
|
+
case TcpClientStates.AUTHENTICATED: {
|
|
217
234
|
client.storage.authenticatedAt = new Date();
|
|
218
235
|
if (client.storage.authenticateTimeout) {
|
|
219
236
|
clearTimeout(client.storage.authenticateTimeout);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-tcp-server.helper.js","sourceRoot":"","sources":["../../../../../src/modules/network/tcp-socket/base-tcp-server.helper.ts"],"names":[],"mappings":";;;AACA,yCAA4C;AAC5C,2CAA2C;AAC3C,6DAAmD;AACnD,iEAA4D;AAmD5D,MAAa,oBAIX,SAAQ,iBAAU;IA6BlB,YACE,IAAsF;QAEtF,KAAK,CAAC;YACJ,KAAK,E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MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;oBACjD,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;gBAC5C,CAAC;gBACD,MAAM;YACR,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAoD;QACvD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEhD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC;YAC7E,OAAO;QACT,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAC;YAChF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;iBACnB,IAAI,CACH,0DAA0D,EAC1D,IAAI,CAAC,UAAU,EACf,QAAQ,CACT,CAAC;YACJ,OAAO;QACT,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;CACF;AArVD,oDAqVC","sourcesContent":["import { type ValueOrPromise } from '@/common/types';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport { getUID } from '@/utilities/parse.utility';\nimport { voidExecution } from '@/utilities/promise.utility';\nimport {\n type ListenOptions,\n type ServerOpts,\n type Socket as SocketClient,\n type Server as SocketServer,\n} from 'node:net';\n\nexport interface ITcpSocketClient<SocketClientType> {\n id: string;\n socket: SocketClientType;\n state: 'unauthorized' | 'authenticating' | 'authenticated';\n subscriptions: Set<string>;\n storage: {\n connectedAt: Date;\n authenticatedAt: Date | null;\n authenticateTimeout?: ReturnType<typeof setTimeout> | null;\n [additionField: symbol | string]: any;\n };\n}\n\nexport interface ITcpSocketServerOptions<\n SocketServerOptions extends ServerOpts = ServerOpts,\n SocketServerType extends SocketServer = SocketServer,\n SocketClientType extends SocketClient = SocketClient,\n> {\n scope?: string;\n identifier: string;\n\n serverOptions: Partial<SocketServerOptions>;\n listenOptions: Partial<ListenOptions>;\n authenticateOptions: { required: boolean; duration?: number };\n\n extraEvents?: Record<\n string,\n (opts: { id: string; socket: SocketClientType; args: any }) => ValueOrPromise<void>\n >;\n\n createServerFn: (\n options: Partial<SocketServerOptions>,\n connectionListener: (socket: SocketClientType) => void,\n ) => SocketServerType;\n\n onServerReady?: (opts: { server: SocketServerType }) => void;\n onClientConnected?: (opts: { id: string; socket: SocketClientType }) => void;\n onClientData?: (opts: { id: string; socket: SocketClientType; data: Buffer | string }) => void;\n onClientClose?: (opts: { id: string; socket: SocketClientType }) => void;\n onClientError?: (opts: { id: string; socket: SocketClientType; error: Error }) => void;\n onServerError?: (opts: { server: SocketServerType; error: Error }) => void;\n}\n\nexport class BaseNetworkTcpServer<\n SocketServerOptions extends ServerOpts = ServerOpts,\n SocketServerType extends SocketServer = SocketServer,\n SocketClientType extends SocketClient = SocketClient,\n> extends BaseHelper {\n protected serverOptions: Partial<SocketServerOptions> = {};\n protected listenOptions: Partial<ListenOptions> = {};\n protected authenticateOptions: { required: boolean; duration?: number };\n\n protected clients: Record<string, ITcpSocketClient<SocketClientType>>;\n protected server: SocketServerType;\n\n protected extraEvents: Record<\n string,\n (opts: { id: string; socket: SocketClientType; args: any }) => ValueOrPromise<void>\n >;\n\n protected createServerFn: (\n options: Partial<SocketServerOptions>,\n connectionListener: (socket: SocketClientType) => void,\n ) => SocketServerType;\n\n protected onServerReady?: (opts: { server: SocketServerType }) => void;\n protected onClientConnected?: (opts: { id: string; socket: SocketClientType }) => void;\n protected onClientData?: (opts: {\n id: string;\n socket: SocketClientType;\n data: Buffer | string;\n }) => void;\n protected onClientClose?: (opts: { id: string; socket: SocketClientType }) => void;\n protected onClientError?: (opts: { id: string; socket: SocketClientType; error: Error }) => void;\n protected onServerError?: (opts: { server: SocketServerType; error: Error }) => void;\n\n constructor(\n opts: ITcpSocketServerOptions<SocketServerOptions, SocketServerType, SocketClientType>,\n ) {\n super({\n scope: opts.scope ?? opts.identifier ?? BaseNetworkTcpServer.name,\n identifier: opts.identifier,\n });\n\n // No prototype: `getClient({ id: 'constructor' })` must find nothing, not `Object`.\n this.clients = Object.create(null);\n\n this.serverOptions = opts.serverOptions;\n this.listenOptions = opts.listenOptions;\n this.authenticateOptions = opts.authenticateOptions;\n\n if (\n this.authenticateOptions.required &&\n (!this.authenticateOptions.duration || this.authenticateOptions.duration < 0)\n ) {\n throw getError({\n message:\n 'TCP Server | Invalid authenticate duration | Required duration for authenticateOptions',\n });\n }\n\n this.extraEvents = opts.extraEvents ?? {};\n\n this.createServerFn = opts.createServerFn;\n\n this.onServerReady = opts.onServerReady;\n this.onClientConnected = opts.onClientConnected;\n this.onClientData = opts.onClientData;\n this.onClientClose = opts.onClientClose;\n this.onClientError = opts.onClientError;\n this.onServerError = opts.onServerError;\n\n this.configure();\n }\n\n // Hooks run inside socket event listeners: a synchronous throw there is an uncaught exception that kills the process and skips the client-registry cleanup that follows it.\n protected invokeHook(opts: { scope: string; execution: () => void }) {\n const { scope, execution } = opts;\n\n try {\n execution();\n } catch (error) {\n this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);\n }\n }\n\n configure() {\n this.server = this.createServerFn(this.serverOptions, (socket) => {\n this.onNewConnection({ socket });\n });\n\n // Without this listener a failed listen - a port already in use is the commonest boot failure there is - emits an unhandled 'error' event, which takes the whole process down with it.\n this.server.on('error', (error: Error) => {\n this.logger\n .for(this.configure.name)\n .error('TCP Socket Server error | Options: %j | Error: %s', this.listenOptions, error);\n\n this.invokeHook({\n scope: this.configure.name,\n execution: () => {\n this.onServerError?.({ server: this.server, error });\n },\n });\n });\n\n this.server.listen(this.listenOptions, () => {\n this.logger\n .for(this.configure.name)\n .info('TCP Socket Server is now listening | Options: %j', this.listenOptions);\n\n this.invokeHook({\n scope: this.configure.name,\n execution: () => {\n this.onServerReady?.({ server: this.server });\n },\n });\n });\n }\n\n onNewConnection(opts: { socket: SocketClientType }) {\n const { socket } = opts;\n\n const id = getUID();\n\n socket.on('data', (data: Buffer | string) => {\n this.invokeHook({\n scope: 'onClientData',\n execution: () => {\n this.onClientData?.({ id, socket, data });\n },\n });\n });\n\n socket.on('error', (error: Error) => {\n this.logger.for('onClientConnect').error('Socket Error | ID: %s | Error: %s', id, error);\n\n this.invokeHook({\n scope: 'onClientError',\n execution: () => {\n this.onClientError?.({ id, socket, error });\n },\n });\n\n socket.end();\n });\n\n socket.on('close', (hasError: boolean) => {\n this.logger\n .for('onClientConnect')\n .info('Socket Closed | ID: %s | hasError: %s', id, hasError);\n\n this.invokeHook({\n scope: 'onClientClose',\n execution: () => {\n this.onClientClose?.({ id, socket });\n },\n });\n\n const authenticateTimeout = this.getClient({ id })?.storage?.authenticateTimeout;\n if (authenticateTimeout) {\n clearTimeout(authenticateTimeout);\n }\n\n // `delete`, not `omit`: omit rebuilds the WHOLE registry per disconnect, so a disconnect\n // storm is O(n^2) - measured at 5000 clients, 2.3s of drain with a 2.2s worst-case stall.\n delete this.clients[id];\n });\n\n for (const extraEvent in this.extraEvents) {\n socket.on(extraEvent, (args) => {\n voidExecution({\n logger: this.logger,\n scope: 'onClientConnect',\n // The async wrapper turns a SYNCHRONOUS throw from the handler into a rejection; calling it bare would throw out of this listener as an uncaught exception.\n execution: (async () => this.extraEvents[extraEvent]({ id, socket, args }))(),\n });\n });\n }\n\n this.clients[id] = {\n id,\n socket,\n state: this.authenticateOptions.required ? 'unauthorized' : 'authenticated',\n subscriptions: new Set([]),\n storage: {\n connectedAt: new Date(),\n authenticatedAt: this.authenticateOptions.required ? null : new Date(),\n },\n };\n\n this.logger\n .for('onClientConnect')\n .info(\n 'New TCP SocketClient | Client: %s | authenticateOptions: %s %s',\n `${id} - ${socket.remoteAddress} - ${socket.remotePort} - ${socket.remoteFamily}`,\n this.authenticateOptions.required,\n this.authenticateOptions.duration,\n );\n\n this.invokeHook({\n scope: 'onClientConnected',\n execution: () => {\n this.onClientConnected?.({ id, socket });\n },\n });\n\n if (\n this.authenticateOptions.required &&\n this.authenticateOptions.duration &&\n this.authenticateOptions.duration > 0\n ) {\n const authenticateTimeout = setTimeout(() => {\n const client = this.getClient({ id });\n if (!client) {\n return;\n }\n\n client.storage.authenticateTimeout = null;\n\n if (client.state === 'authenticated') {\n return;\n }\n\n this.emit({ clientId: id, payload: 'Unauthorized Client' });\n client.socket.end();\n }, this.authenticateOptions.duration);\n\n const client = this.getClient({ id });\n if (!client) {\n clearTimeout(authenticateTimeout);\n return;\n }\n\n client.storage.authenticateTimeout = authenticateTimeout;\n }\n }\n\n getClients() {\n return this.clients;\n }\n\n getClient(opts: { id: string }) {\n return this.clients?.[opts.id];\n }\n\n getServer() {\n return this.server;\n }\n\n /** Clears timers and destroys all client sockets before closing the listener - `server.close()` alone never settles while a socket stays attached. Idempotent; safe if never listened. */\n async shutdown(): Promise<void> {\n const clientsValues = Object.values(this.clients);\n for (const client of clientsValues) {\n const { authenticateTimeout } = client.storage;\n if (authenticateTimeout) {\n clearTimeout(authenticateTimeout);\n client.storage.authenticateTimeout = null;\n }\n\n client.socket.destroy();\n }\n\n this.clients = Object.create(null);\n\n const server = this.server;\n if (!server) {\n return;\n }\n\n // Not guarded on `listening`: listen() is async (DNS lookup), so a shutdown() racing startup could skip close() and leave the server bound forever; close() on a never-listened server just logs ERR_SERVER_NOT_RUNNING below.\n\n await new Promise<void>((resolve) => {\n server.close((error) => {\n if (error) {\n this.logger.for(this.shutdown.name).error('Failed to close server | Error: %s', error);\n }\n\n resolve();\n });\n });\n\n this.logger.for(this.shutdown.name).info('Server closed | Identifier: %s', this.identifier);\n }\n\n doAuthenticate(opts: { id: string; state: 'unauthorized' | 'authenticating' | 'authenticated' }) {\n const { id, state } = opts;\n\n const client = this.getClient({ id });\n if (!client) {\n this.logger.for('authenticateClient').error('Client NOT FOUND | ID: %s', id);\n return;\n }\n\n client.state = state;\n\n switch (state) {\n case 'unauthorized':\n case 'authenticating': {\n client.storage.authenticatedAt = null;\n break;\n }\n case 'authenticated': {\n client.storage.authenticatedAt = new Date();\n\n if (client.storage.authenticateTimeout) {\n clearTimeout(client.storage.authenticateTimeout);\n client.storage.authenticateTimeout = null;\n }\n break;\n }\n default: {\n break;\n }\n }\n }\n\n emit(opts: { clientId: string; payload: Buffer | string }) {\n const { clientId, payload } = opts;\n const client = this.getClient({ id: clientId });\n\n if (!client) {\n this.logger.for(this.emit.name).error('Client NOT FOUND | ID: %s', clientId);\n return;\n }\n\n const { socket } = client;\n if (!socket.writable) {\n this.logger.for(this.emit.name).error('Client NOT WRITABLE | ID: %s', clientId);\n return;\n }\n\n if (!payload?.length) {\n this.logger\n .for(this.emit.name)\n .info(\n '[%s] Client %s | Invalid payload to write to TCP Socket!',\n this.identifier,\n clientId,\n );\n return;\n }\n\n socket.write(payload);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-tcp-server.helper.js","sourceRoot":"","sources":["../../../../../src/modules/network/tcp-socket/base-tcp-server.helper.ts"],"names":[],"mappings":";;;AAEA,yCAA4C;AAC5C,2CAA2C;AAC3C,6DAAmD;AACnD,iEAA4D;AAQ5D,6DAA6D;AAC7D,MAAa,eAAe;aACV,iBAAY,GAAG,cAAc,CAAC;aAC9B,mBAAc,GAAG,gBAAgB,CAAC;aAClC,kBAAa,GAAG,eA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AC;YAChF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;iBACnB,IAAI,CACH,0DAA0D,EAC1D,IAAI,CAAC,UAAU,EACf,QAAQ,CACT,CAAC;YACJ,OAAO;QACT,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;CACF;AAvVD,oDAuVC","sourcesContent":["import type { TConstValue } from '@/common/types';\nimport { type ValueOrPromise } from '@/common/types';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport { getUID } from '@/utilities/parse.utility';\nimport { voidExecution } from '@/utilities/promise.utility';\nimport {\n type ListenOptions,\n type ServerOpts,\n type Socket as SocketClient,\n type Server as SocketServer,\n} from 'node:net';\n\n/** Where a TCP client is in the authentication handshake. */\nexport class TcpClientStates {\n static readonly UNAUTHORIZED = 'unauthorized';\n static readonly AUTHENTICATING = 'authenticating';\n static readonly AUTHENTICATED = 'authenticated';\n\n static readonly SCHEME_SET = new Set<string>([\n this.UNAUTHORIZED,\n this.AUTHENTICATING,\n this.AUTHENTICATED,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid TCP client state values. */\nexport type TTcpClientState = TConstValue<typeof TcpClientStates>;\n\nexport interface ITcpSocketClient<SocketClientType> {\n id: string;\n socket: SocketClientType;\n state: TTcpClientState;\n subscriptions: Set<string>;\n storage: {\n connectedAt: Date;\n authenticatedAt: Date | null;\n authenticateTimeout?: ReturnType<typeof setTimeout> | null;\n [additionField: symbol | string]: any;\n };\n}\n\nexport interface ITcpSocketServerOptions<\n SocketServerOptions extends ServerOpts = ServerOpts,\n SocketServerType extends SocketServer = SocketServer,\n SocketClientType extends SocketClient = SocketClient,\n> {\n scope?: string;\n identifier: string;\n\n serverOptions: Partial<SocketServerOptions>;\n listenOptions: Partial<ListenOptions>;\n authenticateOptions: { required: boolean; duration?: number };\n\n extraEvents?: Record<\n string,\n (opts: { id: string; socket: SocketClientType; args: any }) => ValueOrPromise<void>\n >;\n\n createServerFn: (\n options: Partial<SocketServerOptions>,\n connectionListener: (socket: SocketClientType) => void,\n ) => SocketServerType;\n\n onServerReady?: (opts: { server: SocketServerType }) => void;\n onClientConnected?: (opts: { id: string; socket: SocketClientType }) => void;\n onClientData?: (opts: { id: string; socket: SocketClientType; data: Buffer | string }) => void;\n onClientClose?: (opts: { id: string; socket: SocketClientType }) => void;\n onClientError?: (opts: { id: string; socket: SocketClientType; error: Error }) => void;\n onServerError?: (opts: { server: SocketServerType; error: Error }) => void;\n}\n\nexport class BaseNetworkTcpServer<\n SocketServerOptions extends ServerOpts = ServerOpts,\n SocketServerType extends SocketServer = SocketServer,\n SocketClientType extends SocketClient = SocketClient,\n> extends BaseHelper {\n protected serverOptions: Partial<SocketServerOptions> = {};\n protected listenOptions: Partial<ListenOptions> = {};\n protected authenticateOptions: { required: boolean; duration?: number };\n\n protected clients: Record<string, ITcpSocketClient<SocketClientType>>;\n protected server: SocketServerType;\n\n protected extraEvents: Record<\n string,\n (opts: { id: string; socket: SocketClientType; args: any }) => ValueOrPromise<void>\n >;\n\n protected createServerFn: (\n options: Partial<SocketServerOptions>,\n connectionListener: (socket: SocketClientType) => void,\n ) => SocketServerType;\n\n protected onServerReady?: (opts: { server: SocketServerType }) => void;\n protected onClientConnected?: (opts: { id: string; socket: SocketClientType }) => void;\n protected onClientData?: (opts: {\n id: string;\n socket: SocketClientType;\n data: Buffer | string;\n }) => void;\n protected onClientClose?: (opts: { id: string; socket: SocketClientType }) => void;\n protected onClientError?: (opts: { id: string; socket: SocketClientType; error: Error }) => void;\n protected onServerError?: (opts: { server: SocketServerType; error: Error }) => void;\n\n constructor(\n opts: ITcpSocketServerOptions<SocketServerOptions, SocketServerType, SocketClientType>,\n ) {\n super({\n scope: opts.scope ?? opts.identifier ?? BaseNetworkTcpServer.name,\n identifier: opts.identifier,\n });\n\n // No prototype: `getClient({ id: 'constructor' })` must find nothing, not `Object`.\n this.clients = Object.create(null);\n\n this.serverOptions = opts.serverOptions;\n this.listenOptions = opts.listenOptions;\n this.authenticateOptions = opts.authenticateOptions;\n\n if (\n this.authenticateOptions.required &&\n (!this.authenticateOptions.duration || this.authenticateOptions.duration < 0)\n ) {\n throw getError({\n message:\n 'TCP Server | Invalid authenticate duration | Required duration for authenticateOptions',\n });\n }\n\n this.extraEvents = opts.extraEvents ?? {};\n\n this.createServerFn = opts.createServerFn;\n\n this.onServerReady = opts.onServerReady;\n this.onClientConnected = opts.onClientConnected;\n this.onClientData = opts.onClientData;\n this.onClientClose = opts.onClientClose;\n this.onClientError = opts.onClientError;\n this.onServerError = opts.onServerError;\n\n this.configure();\n }\n\n // Hooks run inside socket event listeners: a synchronous throw there is an uncaught exception that kills the process and skips the client-registry cleanup that follows it.\n protected invokeHook(opts: { scope: string; execution: () => void }) {\n const { scope, execution } = opts;\n\n try {\n execution();\n } catch (error) {\n this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);\n }\n }\n\n configure() {\n this.server = this.createServerFn(this.serverOptions, (socket) => {\n this.onNewConnection({ socket });\n });\n\n // Without this listener a failed listen - a port already in use is the commonest boot failure there is - emits an unhandled 'error' event, which takes the whole process down with it.\n this.server.on('error', (error: Error) => {\n this.logger\n .for(this.configure.name)\n .error('TCP Socket Server error | Options: %j | Error: %s', this.listenOptions, error);\n\n this.invokeHook({\n scope: this.configure.name,\n execution: () => {\n this.onServerError?.({ server: this.server, error });\n },\n });\n });\n\n this.server.listen(this.listenOptions, () => {\n this.logger\n .for(this.configure.name)\n .info('TCP Socket Server is now listening | Options: %j', this.listenOptions);\n\n this.invokeHook({\n scope: this.configure.name,\n execution: () => {\n this.onServerReady?.({ server: this.server });\n },\n });\n });\n }\n\n onNewConnection(opts: { socket: SocketClientType }) {\n const { socket } = opts;\n\n const id = getUID();\n\n socket.on('data', (data: Buffer | string) => {\n this.invokeHook({\n scope: 'onClientData',\n execution: () => {\n this.onClientData?.({ id, socket, data });\n },\n });\n });\n\n socket.on('error', (error: Error) => {\n this.logger.for('onClientConnect').error('Socket Error | ID: %s | Error: %s', id, error);\n\n this.invokeHook({\n scope: 'onClientError',\n execution: () => {\n this.onClientError?.({ id, socket, error });\n },\n });\n\n socket.end();\n });\n\n socket.on('close', (hasError: boolean) => {\n this.logger\n .for('onClientConnect')\n .info('Socket Closed | ID: %s | hasError: %s', id, hasError);\n\n this.invokeHook({\n scope: 'onClientClose',\n execution: () => {\n this.onClientClose?.({ id, socket });\n },\n });\n\n const authenticateTimeout = this.getClient({ id })?.storage?.authenticateTimeout;\n if (authenticateTimeout) {\n clearTimeout(authenticateTimeout);\n }\n\n // `delete`, not `omit`: omit rebuilds the WHOLE registry per disconnect, so a disconnect\n // storm is O(n^2) - measured at 5000 clients, 2.3s of drain with a 2.2s worst-case stall.\n delete this.clients[id];\n });\n\n for (const extraEvent in this.extraEvents) {\n socket.on(extraEvent, (args) => {\n voidExecution({\n logger: this.logger,\n scope: 'onClientConnect',\n // The async wrapper turns a SYNCHRONOUS throw from the handler into a rejection; calling it bare would throw out of this listener as an uncaught exception.\n execution: (async () => this.extraEvents[extraEvent]({ id, socket, args }))(),\n });\n });\n }\n\n this.clients[id] = {\n id,\n socket,\n state: this.authenticateOptions.required\n ? TcpClientStates.UNAUTHORIZED\n : TcpClientStates.AUTHENTICATED,\n subscriptions: new Set([]),\n storage: {\n connectedAt: new Date(),\n authenticatedAt: this.authenticateOptions.required ? null : new Date(),\n },\n };\n\n this.logger\n .for('onClientConnect')\n .info(\n 'New TCP SocketClient | Client: %s | authenticateOptions: %s %s',\n `${id} - ${socket.remoteAddress} - ${socket.remotePort} - ${socket.remoteFamily}`,\n this.authenticateOptions.required,\n this.authenticateOptions.duration,\n );\n\n this.invokeHook({\n scope: 'onClientConnected',\n execution: () => {\n this.onClientConnected?.({ id, socket });\n },\n });\n\n if (\n this.authenticateOptions.required &&\n this.authenticateOptions.duration &&\n this.authenticateOptions.duration > 0\n ) {\n const authenticateTimeout = setTimeout(() => {\n const client = this.getClient({ id });\n if (!client) {\n return;\n }\n\n client.storage.authenticateTimeout = null;\n\n if (client.state === TcpClientStates.AUTHENTICATED) {\n return;\n }\n\n this.emit({ clientId: id, payload: 'Unauthorized Client' });\n client.socket.end();\n }, this.authenticateOptions.duration);\n\n const client = this.getClient({ id });\n if (!client) {\n clearTimeout(authenticateTimeout);\n return;\n }\n\n client.storage.authenticateTimeout = authenticateTimeout;\n }\n }\n\n getClients() {\n return this.clients;\n }\n\n getClient(opts: { id: string }) {\n return this.clients?.[opts.id];\n }\n\n getServer() {\n return this.server;\n }\n\n /** Clears timers and destroys all client sockets before closing the listener - `server.close()` alone never settles while a socket stays attached. Idempotent; safe if never listened. */\n async shutdown(): Promise<void> {\n const clientsValues = Object.values(this.clients);\n for (const client of clientsValues) {\n const { authenticateTimeout } = client.storage;\n if (authenticateTimeout) {\n clearTimeout(authenticateTimeout);\n client.storage.authenticateTimeout = null;\n }\n\n client.socket.destroy();\n }\n\n this.clients = Object.create(null);\n\n const server = this.server;\n if (!server) {\n return;\n }\n\n // Not guarded on `listening`: listen() is async (DNS lookup), so a shutdown() racing startup could skip close() and leave the server bound forever; close() on a never-listened server just logs ERR_SERVER_NOT_RUNNING below.\n\n await new Promise<void>((resolve) => {\n server.close((error) => {\n if (error) {\n this.logger.for(this.shutdown.name).error('Failed to close server | Error: %s', error);\n }\n\n resolve();\n });\n });\n\n this.logger.for(this.shutdown.name).info('Server closed | Identifier: %s', this.identifier);\n }\n\n doAuthenticate(opts: { id: string; state: TTcpClientState }) {\n const { id, state } = opts;\n\n const client = this.getClient({ id });\n if (!client) {\n this.logger.for('authenticateClient').error('Client NOT FOUND | ID: %s', id);\n return;\n }\n\n client.state = state;\n\n switch (state) {\n case TcpClientStates.UNAUTHORIZED:\n case TcpClientStates.AUTHENTICATING: {\n client.storage.authenticatedAt = null;\n break;\n }\n case TcpClientStates.AUTHENTICATED: {\n client.storage.authenticatedAt = new Date();\n\n if (client.storage.authenticateTimeout) {\n clearTimeout(client.storage.authenticateTimeout);\n client.storage.authenticateTimeout = null;\n }\n break;\n }\n default: {\n break;\n }\n }\n }\n\n emit(opts: { clientId: string; payload: Buffer | string }) {\n const { clientId, payload } = opts;\n const client = this.getClient({ id: clientId });\n\n if (!client) {\n this.logger.for(this.emit.name).error('Client NOT FOUND | ID: %s', clientId);\n return;\n }\n\n const { socket } = client;\n if (!socket.writable) {\n this.logger.for(this.emit.name).error('Client NOT WRITABLE | ID: %s', clientId);\n return;\n }\n\n if (!payload?.length) {\n this.logger\n .for(this.emit.name)\n .info(\n '[%s] Client %s | Invalid payload to write to TCP Socket!',\n this.identifier,\n clientId,\n );\n return;\n }\n\n socket.write(payload);\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TConstValue } from '../../../common/types';
|
|
2
|
+
/** What a BullMQ helper is: the QUEUE that jobs are added to, or the WORKER that runs them. */
|
|
3
|
+
export declare class BullQueueRoles {
|
|
4
|
+
static readonly QUEUE = "queue";
|
|
5
|
+
static readonly WORKER = "worker";
|
|
6
|
+
static readonly SCHEME_SET: Set<string>;
|
|
7
|
+
static isValid(value: string): boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Valid BullMQ queue role values. */
|
|
10
|
+
export type TBullQueueRole = TConstValue<typeof BullQueueRoles>;
|
|
11
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,+FAA+F;AAC/F,qBAAa,cAAc;IACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAElC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA8C;IAExE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,sCAAsC;AACtC,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BullQueueRoles = void 0;
|
|
4
|
+
/** What a BullMQ helper is: the QUEUE that jobs are added to, or the WORKER that runs them. */
|
|
5
|
+
class BullQueueRoles {
|
|
6
|
+
static { this.QUEUE = 'queue'; }
|
|
7
|
+
static { this.WORKER = 'worker'; }
|
|
8
|
+
static { this.SCHEME_SET = new Set([this.QUEUE, this.WORKER]); }
|
|
9
|
+
static isValid(value) {
|
|
10
|
+
return this.SCHEME_SET.has(value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.BullQueueRoles = BullQueueRoles;
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/constants.ts"],"names":[],"mappings":";;;AAEA,+FAA+F;AAC/F,MAAa,cAAc;aACT,UAAK,GAAG,OAAO,CAAC;aAChB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,wCASC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** What a BullMQ helper is: the QUEUE that jobs are added to, or the WORKER that runs them. */\nexport class BullQueueRoles {\n static readonly QUEUE = 'queue';\n static readonly WORKER = 'worker';\n\n static readonly SCHEME_SET = new Set<string>([this.QUEUE, this.WORKER]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid BullMQ queue role values. */\nexport type TBullQueueRole = TConstValue<typeof BullQueueRoles>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
17
18
|
__exportStar(require("./hook"), exports);
|
|
18
19
|
__exportStar(require("./types"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB","sourcesContent":["export * from './hook';\nexport * from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB","sourcesContent":["export * from './constants';\nexport * from './hook';\nexport * from './types';\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -56,4 +56,13 @@ export declare class KafkaDefaults {
|
|
|
56
56
|
static readonly SHUTDOWN_TIMEOUT = 30000;
|
|
57
57
|
static readonly LAG_MONITOR_INTERVAL = 30000;
|
|
58
58
|
}
|
|
59
|
+
/** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */
|
|
60
|
+
export declare class KafkaBrokersDownReasons {
|
|
61
|
+
static readonly DISCONNECTED = "disconnected";
|
|
62
|
+
static readonly FAILED = "failed";
|
|
63
|
+
static readonly SCHEME_SET: Set<string>;
|
|
64
|
+
static isValid(value: string): boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Valid Kafka brokers-down reason values. */
|
|
67
|
+
export type TKafkaBrokersDownReason = TConstValue<typeof KafkaBrokersDownReasons>;
|
|
59
68
|
//# 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":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,OAA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AAuB;IAClC,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAElC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAqD;IAE/E,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,8CAA8C;AAC9C,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KafkaDefaults = exports.KafkaClientEvents = exports.KafkaHealthStatuses = exports.KafkaAcks = exports.KafkaGroupProtocol = void 0;
|
|
3
|
+
exports.KafkaBrokersDownReasons = exports.KafkaDefaults = exports.KafkaClientEvents = exports.KafkaHealthStatuses = exports.KafkaAcks = exports.KafkaGroupProtocol = void 0;
|
|
4
4
|
class KafkaGroupProtocol {
|
|
5
5
|
static { this.CLASSIC = 'classic'; }
|
|
6
6
|
static { this.CONSUMER = 'consumer'; }
|
|
@@ -69,4 +69,14 @@ class KafkaDefaults {
|
|
|
69
69
|
static { this.LAG_MONITOR_INTERVAL = 30_000; }
|
|
70
70
|
}
|
|
71
71
|
exports.KafkaDefaults = KafkaDefaults;
|
|
72
|
+
/** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */
|
|
73
|
+
class KafkaBrokersDownReasons {
|
|
74
|
+
static { this.DISCONNECTED = 'disconnected'; }
|
|
75
|
+
static { this.FAILED = 'failed'; }
|
|
76
|
+
static { this.SCHEME_SET = new Set([this.DISCONNECTED, this.FAILED]); }
|
|
77
|
+
static isValid(value) {
|
|
78
|
+
return this.SCHEME_SET.has(value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.KafkaBrokersDownReasons = KafkaBrokersDownReasons;
|
|
72
82
|
//# sourceMappingURL=constants.js.map
|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mBAAc,GAAG,uBAAuB,CAAC;aACzC,sBAAiB,GAAG,0BAA0B,CAAC;aAC/C,kBAAa,GAAG,sBAAsB,CAAC;aAEvC,wBAAmB,GAAG,qBAAqB,CAAC;aAC5C,yBAAoB,GAAG,sBAAsB,CAAC;aAC9C,6BAAwB,GAAG,0BAA0B,CAAC;aACtD,6BAAwB,GAAG,0BAA0B,CAAC;aACtD,iBAAY,GAAG,cAAc,CAAC;aAC9B,uBAAkB,GAAG,oBAAoB,CAAC;aAE1C,gBAAW,GAAG,MAAM,CAAC;aACrB,iBAAY,GAAG,OAAO,CAAC;;AAbzC,8CAcC;AAED,MAAa,aAAa;IACxB,SAAS;aACO,YAAO,GAAG,CAAC,CAAC;aACZ,gBAAW,GAAG,KAAK,CAAC;IAEpC,WAAW;aACK,WAAM,GAAG,IAAI,CAAC;aACd,sBAAiB,GAAG,KAAK,CAAC;IAE1C,WAAW;aACK,eAAU,GAAG,KAAK,CAAC;aACnB,oBAAe,GAAG,MAAM,CAAC;aACzB,uBAAkB,GAAG,MAAM,CAAC;aAC5B,oBAAe,GAAG,IAAI,CAAC;aACvB,cAAS,GAAG,CAAC,CAAC;aACd,cAAS,GAAG,SAAS,GAAG,EAAE,CAAC,GAAC,QAAQ;aACpC,kBAAa,GAAG,KAAK,CAAC;aACtB,qBAAgB,GAAG,OAAO,CAAC;aAC3B,mBAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;aAE5C,iBAAY,GAAG,WAAW,CAAC;aAC3B,0BAAqB,GAAG,QAAQ,CAAC;aAEjC,oBAAe,GAAG,KAAK,CAAC;aACxB,2BAAsB,GAAG,CAAC,CAAC;aAC3B,qBAAgB,GAAG,MAAM,CAAC;aAC1B,yBAAoB,GAAG,MAAM,CAAC;;AA1BhD,sCA2BC","sourcesContent":["import { type TConstValue } from '@/common';\n\nexport class KafkaGroupProtocol {\n static readonly CLASSIC = 'classic';\n static readonly CONSUMER = 'consumer';\n\n static readonly SCHEME_SET = new Set([this.CLASSIC, this.CONSUMER]);\n\n static isValid(mode: string): boolean {\n return this.SCHEME_SET.has(mode);\n }\n}\n\nexport type TKafkaGroupProtocol = TConstValue<typeof KafkaGroupProtocol>;\n\nexport class KafkaAcks {\n static readonly NONE = 0; // No acknowledgment — fire-and-forget\n static readonly LEADER = 1; // Leader acknowledgment only\n static readonly ALL = -1; // Full ISR acknowledgment\n\n static readonly SCHEME_SET = new Set([this.NONE, this.LEADER, this.ALL]);\n\n static isValid(ack: number): boolean {\n return this.SCHEME_SET.has(ack);\n }\n}\n\nexport type TKafkaAcks = TConstValue<typeof KafkaAcks>;\n\nexport class KafkaHealthStatuses {\n static readonly CONNECTED = 'connected';\n static readonly DISCONNECTED = 'disconnected';\n static readonly UNKNOWN = 'unknown';\n\n static readonly SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]);\n\n static isValid(status: string): boolean {\n return this.SCHEME_SET.has(status);\n }\n}\n\nexport type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;\n\nexport class KafkaClientEvents {\n static readonly BROKER_CONNECT = 'client:broker:connect';\n static readonly BROKER_DISCONNECT = 'client:broker:disconnect';\n static readonly BROKER_FAILED = 'client:broker:failed';\n\n static readonly CONSUMER_GROUP_JOIN = 'consumer:group:join';\n static readonly CONSUMER_GROUP_LEAVE = 'consumer:group:leave';\n static readonly CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance';\n static readonly CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error';\n static readonly CONSUMER_LAG = 'consumer:lag';\n static readonly CONSUMER_LAG_ERROR = 'consumer:lag:error';\n\n static readonly STREAM_DATA = 'data';\n static readonly STREAM_ERROR = 'error';\n}\n\nexport class KafkaDefaults {\n // Shared\n static readonly RETRIES = 3;\n static readonly RETRY_DELAY = 1_000;\n\n // Producer\n static readonly STRICT = true;\n static readonly AUTOCREATE_TOPICS = false;\n\n // Consumer\n static readonly AUTOCOMMIT = false;\n static readonly SESSION_TIMEOUT = 60_000;\n static readonly HEARTBEAT_INTERVAL = 10_000;\n static readonly HIGH_WATER_MARK = 1024;\n static readonly MIN_BYTES = 1;\n static readonly MAX_BYTES = 1_048_576 * 10; // 10 MB\n static readonly MAX_WAIT_TIME = 5_000;\n static readonly METADATA_MAX_AGE = 300_000;\n static readonly GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC;\n\n static readonly CONSUME_MODE = 'committed';\n static readonly CONSUME_FALLBACK_MODE = 'latest';\n\n static readonly RECONNECT_DELAY = 2_000;\n static readonly MAX_RECONNECT_ATTEMPTS = 5;\n static readonly SHUTDOWN_TIMEOUT = 30_000;\n static readonly LAG_MONITOR_INTERVAL = 30_000;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":";;;AAEA,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,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,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AG,OAAO,CAAC;aAC3B,mBAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;aAE5C,iBAAY,GAAG,WAAW,CAAC;aAC3B,0BAAqB,GAAG,QAAQ,CAAC;aAEjC,oBAAe,GAAG,KAAK,CAAC;aACxB,2BAAsB,GAAG,CAAC,CAAC;aAC3B,qBAAgB,GAAG,MAAM,CAAC;aAC1B,yBAAoB,GAAG,MAAM,CAAC;;AA1BhD,sCA2BC;AAED,8GAA8G;AAC9G,MAAa,uBAAuB;aAClB,iBAAY,GAAG,cAAc,CAAC;aAC9B,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,0DASC","sourcesContent":["import { type TConstValue } from '@/common';\n\nexport class KafkaGroupProtocol {\n static readonly CLASSIC = 'classic';\n static readonly CONSUMER = 'consumer';\n\n static readonly SCHEME_SET = new Set([this.CLASSIC, this.CONSUMER]);\n\n static isValid(mode: string): boolean {\n return this.SCHEME_SET.has(mode);\n }\n}\n\nexport type TKafkaGroupProtocol = TConstValue<typeof KafkaGroupProtocol>;\n\nexport class KafkaAcks {\n static readonly NONE = 0; // No acknowledgment — fire-and-forget\n static readonly LEADER = 1; // Leader acknowledgment only\n static readonly ALL = -1; // Full ISR acknowledgment\n\n static readonly SCHEME_SET = new Set([this.NONE, this.LEADER, this.ALL]);\n\n static isValid(ack: number): boolean {\n return this.SCHEME_SET.has(ack);\n }\n}\n\nexport type TKafkaAcks = TConstValue<typeof KafkaAcks>;\n\nexport class KafkaHealthStatuses {\n static readonly CONNECTED = 'connected';\n static readonly DISCONNECTED = 'disconnected';\n static readonly UNKNOWN = 'unknown';\n\n static readonly SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]);\n\n static isValid(status: string): boolean {\n return this.SCHEME_SET.has(status);\n }\n}\n\nexport type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;\n\nexport class KafkaClientEvents {\n static readonly BROKER_CONNECT = 'client:broker:connect';\n static readonly BROKER_DISCONNECT = 'client:broker:disconnect';\n static readonly BROKER_FAILED = 'client:broker:failed';\n\n static readonly CONSUMER_GROUP_JOIN = 'consumer:group:join';\n static readonly CONSUMER_GROUP_LEAVE = 'consumer:group:leave';\n static readonly CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance';\n static readonly CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error';\n static readonly CONSUMER_LAG = 'consumer:lag';\n static readonly CONSUMER_LAG_ERROR = 'consumer:lag:error';\n\n static readonly STREAM_DATA = 'data';\n static readonly STREAM_ERROR = 'error';\n}\n\nexport class KafkaDefaults {\n // Shared\n static readonly RETRIES = 3;\n static readonly RETRY_DELAY = 1_000;\n\n // Producer\n static readonly STRICT = true;\n static readonly AUTOCREATE_TOPICS = false;\n\n // Consumer\n static readonly AUTOCOMMIT = false;\n static readonly SESSION_TIMEOUT = 60_000;\n static readonly HEARTBEAT_INTERVAL = 10_000;\n static readonly HIGH_WATER_MARK = 1024;\n static readonly MIN_BYTES = 1;\n static readonly MAX_BYTES = 1_048_576 * 10; // 10 MB\n static readonly MAX_WAIT_TIME = 5_000;\n static readonly METADATA_MAX_AGE = 300_000;\n static readonly GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC;\n\n static readonly CONSUME_MODE = 'committed';\n static readonly CONSUME_FALLBACK_MODE = 'latest';\n\n static readonly RECONNECT_DELAY = 2_000;\n static readonly MAX_RECONNECT_ATTEMPTS = 5;\n static readonly SHUTDOWN_TIMEOUT = 30_000;\n static readonly LAG_MONITOR_INTERVAL = 30_000;\n}\n\n/** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */\nexport class KafkaBrokersDownReasons {\n static readonly DISCONNECTED = 'disconnected';\n static readonly FAILED = 'failed';\n\n static readonly SCHEME_SET = new Set<string>([this.DISCONNECTED, this.FAILED]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid Kafka brokers-down reason values. */\nexport type TKafkaBrokersDownReason = TConstValue<typeof KafkaBrokersDownReasons>;\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MessagesStream } from '@platformatic/kafka';
|
|
2
2
|
import { Consumer } from '@platformatic/kafka';
|
|
3
3
|
import { BaseKafkaHelper } from './base';
|
|
4
|
+
import { type TKafkaBrokersDownReason } from './common/constants';
|
|
4
5
|
import type { IKafkaConsumeStartOptions, IKafkaConsumerOptions, TKafkaGroupJoinCallback, TKafkaGroupLeaveCallback, TKafkaGroupRebalanceCallback, TKafkaHeartbeatErrorCallback, TKafkaLagCallback, TKafkaLagErrorCallback, TKafkaMessageCallback, TKafkaMessageDoneCallback, TKafkaMessageErrorCallback, TKafkaReconnectErrorCallback, TKafkaStreamErrorCallback } from './common/types';
|
|
5
6
|
/**
|
|
6
7
|
* Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.
|
|
@@ -78,7 +79,7 @@ export declare class KafkaConsumerHelper<KeyType = string, ValueType = string, H
|
|
|
78
79
|
}): Promise<void>;
|
|
79
80
|
protected rebuildClient(): Promise<void>;
|
|
80
81
|
protected closeOldClient(oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>): Promise<void>;
|
|
81
|
-
protected handleAllBrokersDown(reason:
|
|
82
|
+
protected handleAllBrokersDown(reason: TKafkaBrokersDownReason): void;
|
|
82
83
|
protected destroyDeadStream(): void;
|
|
83
84
|
protected closeStream(): Promise<void>;
|
|
84
85
|
protected unconfigureBrokerEvents(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAKV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAKV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAKL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;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,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,CAAC,GAAG,IAAI,CACpF;IACP,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IACnD,SAAS,CAAC,mBAAmB,EAAE,yBAAyB,GAAG,IAAI,CAAQ;IACvE,SAAS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AAa,IAAI,OAAO,CAAC,IAAI,CAAC;cAoC9B,cAAc,CAC5B,SAAS,EAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,CAAC,GACtE,OAAO,CAAC,IAAI,CAAC;IAwBhB,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAcrE,SAAS,CAAC,iBAAiB,IAAI,IAAI;cAKnB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;cAezB,uBAAuB,IAAI,IAAI;cAU/B,qBAAqB,IAAI,IAAI;CAoGjD"}
|
|
@@ -397,10 +397,10 @@ class KafkaConsumerHelper extends base_1.BaseKafkaHelper {
|
|
|
397
397
|
configureBrokerEvents() {
|
|
398
398
|
super.configureBrokerEvents();
|
|
399
399
|
this.client.on(constants_1.KafkaClientEvents.BROKER_DISCONNECT, () => {
|
|
400
|
-
this.handleAllBrokersDown(
|
|
400
|
+
this.handleAllBrokersDown(constants_1.KafkaBrokersDownReasons.DISCONNECTED);
|
|
401
401
|
});
|
|
402
402
|
this.client.on(constants_1.KafkaClientEvents.BROKER_FAILED, () => {
|
|
403
|
-
this.handleAllBrokersDown(
|
|
403
|
+
this.handleAllBrokersDown(constants_1.KafkaBrokersDownReasons.FAILED);
|
|
404
404
|
});
|
|
405
405
|
this.client.on(constants_1.KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload) => {
|
|
406
406
|
this.logger.info('[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d', payload.groupId, payload.memberId, payload.generationId);
|