@xnestjs/kafka 1.5.2 → 1.5.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/README.md +1 -1
- package/cjs/get-connection-options.js +64 -0
- package/cjs/index.js +1 -0
- package/cjs/kafka-core.module.js +3 -61
- package/esm/get-connection-options.js +60 -0
- package/esm/index.js +1 -0
- package/esm/kafka-core.module.js +3 -61
- package/package.json +1 -1
- package/types/get-connection-options.d.ts +2 -0
- package/types/index.d.cts +1 -0
- package/types/index.d.ts +1 -0
- package/types/kafka-core.module.d.ts +0 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ All environment variables starts with prefix (KAFKA_). This can be configured wh
|
|
|
64
64
|
|
|
65
65
|
| Environment Variable | Type | Default | Description |
|
|
66
66
|
|-------------------------------|-----------|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
67
|
-
|
|
|
67
|
+
| KAFKA_BROKERS | String[]! | localhost | Host names of Kafka brokers |
|
|
68
68
|
| KAFKA_CONSUMER_GROUP_ID | String | kafka_default_group | |
|
|
69
69
|
| KAFKA_CLIENT_ID | String | | |
|
|
70
70
|
| KAFKA_SASL | Enum | | Defines the SASL Mechanism. Accepted values are (`plain`, `scram-sha-256`, `scram-sha-512`, `aws`) |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConnectionOptions = getConnectionOptions;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
6
|
+
const objects_1 = require("@jsopen/objects");
|
|
7
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
8
|
+
function getConnectionOptions(moduleOptions, envPrefix = 'KAFKA_') {
|
|
9
|
+
const options = (0, objects_1.clone)(moduleOptions);
|
|
10
|
+
const env = node_process_1.default.env;
|
|
11
|
+
options.brokers = options.brokers || (env[envPrefix + 'BROKERS'] ?? 'localhost').split(/\s*,\s*/);
|
|
12
|
+
if (options.ssl == null && (0, putil_varhelpers_1.toBoolean)(env[envPrefix + 'SSL'])) {
|
|
13
|
+
options.ssl = {
|
|
14
|
+
ca: [env[envPrefix + 'SSL_CA_CERT'] || ''],
|
|
15
|
+
cert: env[envPrefix + 'SSL_CERT_FILE'],
|
|
16
|
+
key: env[envPrefix + 'SSL_KEY_FILE'],
|
|
17
|
+
passphrase: env[envPrefix + 'SSL_KEY_PASSPHRASE'],
|
|
18
|
+
rejectUnauthorized: (0, putil_varhelpers_1.toBoolean)(env[envPrefix + 'SSL_REJECT_UNAUTHORIZED']),
|
|
19
|
+
checkServerIdentity: (host, cert) => {
|
|
20
|
+
if (cert.subject.CN !== host) {
|
|
21
|
+
return new Error(`Certificate CN (${cert.subject.CN}) does not match host (${host})`);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const sasl = env[envPrefix + 'SASL'];
|
|
27
|
+
if (options.sasl == null && sasl) {
|
|
28
|
+
if (sasl === 'plain' || sasl === 'scram-sha-256' || sasl === 'scram-sha-512') {
|
|
29
|
+
options.sasl = {
|
|
30
|
+
mechanism: sasl,
|
|
31
|
+
username: env[envPrefix + 'SASL_USERNAME'] || '',
|
|
32
|
+
password: env[envPrefix + 'SASL_PASSWORD'] || '',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (sasl === 'aws') {
|
|
36
|
+
options.sasl = {
|
|
37
|
+
mechanism: sasl,
|
|
38
|
+
authorizationIdentity: env[envPrefix + 'AWS_AUTH_IDENTITY'] || '',
|
|
39
|
+
accessKeyId: env[envPrefix + 'AWS_ACCESS_KEY_ID'] || '',
|
|
40
|
+
secretAccessKey: env[envPrefix + 'AWS_SECRET_ACCESS_KEY'] || '',
|
|
41
|
+
sessionToken: env[envPrefix + 'AWS_SESSION_TOKEN'],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
options.clientId = options.clientId ?? env[envPrefix + 'CLIENT_ID'];
|
|
46
|
+
options.connectionTimeout = options.connectionTimeout ?? (0, putil_varhelpers_1.toInt)(env[envPrefix + 'CONNECT_TIMEOUT']);
|
|
47
|
+
options.authenticationTimeout = options.authenticationTimeout ?? (0, putil_varhelpers_1.toInt)(env[envPrefix + 'AUTH_TIMEOUT']);
|
|
48
|
+
options.reauthenticationThreshold = options.reauthenticationThreshold ?? (0, putil_varhelpers_1.toInt)(env[envPrefix + 'REAUTH_THRESHOLD']);
|
|
49
|
+
options.requestTimeout = options.requestTimeout ?? (0, putil_varhelpers_1.toInt)(env[envPrefix + 'REQUEST_TIMEOUT']);
|
|
50
|
+
options.enforceRequestTimeout =
|
|
51
|
+
options.enforceRequestTimeout ?? (0, putil_varhelpers_1.toBoolean)(env[envPrefix + 'ENFORCE_REQUEST_TIMEOUT']);
|
|
52
|
+
const retries = (0, putil_varhelpers_1.toInt)(env[envPrefix + 'RETRIES']);
|
|
53
|
+
if (options.retry == null && retries) {
|
|
54
|
+
options.retry = {
|
|
55
|
+
maxRetryTime: (0, putil_varhelpers_1.toInt)(env[envPrefix + 'RETRY_MAX_TIME']),
|
|
56
|
+
initialRetryTime: (0, putil_varhelpers_1.toInt)(env[envPrefix + 'RETRY_INITIAL_TIME']),
|
|
57
|
+
retries,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
options.consumer = options.consumer || {};
|
|
61
|
+
options.consumer.groupId =
|
|
62
|
+
options.consumer.groupId ?? (env[envPrefix + 'CONSUMER_GROUP_ID'] || 'kafka_default_group');
|
|
63
|
+
return options;
|
|
64
|
+
}
|
package/cjs/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClientKafka = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./get-connection-options.js"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./kafka.module.js"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
8
9
|
var microservices_1 = require("@nestjs/microservices");
|
package/cjs/kafka-core.module.js
CHANGED
|
@@ -5,21 +5,19 @@ exports.KafkaCoreModule = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
|
|
7
7
|
const crypto = tslib_1.__importStar(require("node:crypto"));
|
|
8
|
-
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
9
|
-
const objects_1 = require("@jsopen/objects");
|
|
10
8
|
const common_1 = require("@nestjs/common");
|
|
11
9
|
const microservices_1 = require("@nestjs/microservices");
|
|
12
10
|
const colors = tslib_1.__importStar(require("ansi-colors"));
|
|
13
|
-
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
14
11
|
const constants_js_1 = require("./constants.js");
|
|
15
12
|
const create_log_creator_js_1 = require("./create-log-creator.js");
|
|
13
|
+
const get_connection_options_js_1 = require("./get-connection-options.js");
|
|
16
14
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
17
15
|
let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
18
16
|
/**
|
|
19
17
|
*
|
|
20
18
|
*/
|
|
21
19
|
static forRoot(moduleOptions) {
|
|
22
|
-
const connectionOptions =
|
|
20
|
+
const connectionOptions = (0, get_connection_options_js_1.getConnectionOptions)(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
23
21
|
return this._createDynamicModule(moduleOptions, {
|
|
24
22
|
global: moduleOptions.global,
|
|
25
23
|
providers: [
|
|
@@ -43,7 +41,7 @@ let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
|
43
41
|
inject: asyncOptions.inject,
|
|
44
42
|
useFactory: async (...args) => {
|
|
45
43
|
const opts = await asyncOptions.useFactory(...args);
|
|
46
|
-
return
|
|
44
|
+
return (0, get_connection_options_js_1.getConnectionOptions)(opts, asyncOptions.envPrefix);
|
|
47
45
|
},
|
|
48
46
|
},
|
|
49
47
|
],
|
|
@@ -106,62 +104,6 @@ let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
|
106
104
|
exports,
|
|
107
105
|
};
|
|
108
106
|
}
|
|
109
|
-
static _readConnectionOptions(moduleOptions, prefix = 'KAFKA_') {
|
|
110
|
-
const options = (0, objects_1.clone)(moduleOptions);
|
|
111
|
-
const env = node_process_1.default.env;
|
|
112
|
-
options.brokers = options.brokers || (env[prefix + 'URL'] ?? 'localhost').split(/\s*,\s*/);
|
|
113
|
-
if (options.ssl == null && (0, putil_varhelpers_1.toBoolean)(env[prefix + 'SSL'])) {
|
|
114
|
-
options.ssl = {
|
|
115
|
-
ca: [env[prefix + 'SSL_CA_CERT'] || ''],
|
|
116
|
-
cert: env[prefix + 'SSL_CERT_FILE'],
|
|
117
|
-
key: env[prefix + 'SSL_KEY_FILE'],
|
|
118
|
-
passphrase: env[prefix + 'SSL_KEY_PASSPHRASE'],
|
|
119
|
-
rejectUnauthorized: (0, putil_varhelpers_1.toBoolean)(env[prefix + 'SSL_REJECT_UNAUTHORIZED']),
|
|
120
|
-
checkServerIdentity: (host, cert) => {
|
|
121
|
-
if (cert.subject.CN !== host) {
|
|
122
|
-
return new Error(`Certificate CN (${cert.subject.CN}) does not match host (${host})`);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
const sasl = env[prefix + 'SASL'];
|
|
128
|
-
if (options.sasl == null && sasl) {
|
|
129
|
-
if (sasl === 'plain' || sasl === 'scram-sha-256' || sasl === 'scram-sha-512') {
|
|
130
|
-
options.sasl = {
|
|
131
|
-
mechanism: sasl,
|
|
132
|
-
username: env[prefix + 'SASL_USERNAME'] || '',
|
|
133
|
-
password: env[prefix + 'SASL_PASSWORD'] || '',
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
else if (sasl === 'aws') {
|
|
137
|
-
options.sasl = {
|
|
138
|
-
mechanism: sasl,
|
|
139
|
-
authorizationIdentity: env[prefix + 'AWS_AUTH_IDENTITY'] || '',
|
|
140
|
-
accessKeyId: env[prefix + 'AWS_ACCESS_KEY_ID'] || '',
|
|
141
|
-
secretAccessKey: env[prefix + 'AWS_SECRET_ACCESS_KEY'] || '',
|
|
142
|
-
sessionToken: env[prefix + 'AWS_SESSION_TOKEN'],
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
options.clientId = options.clientId ?? env[prefix + 'CLIENT_ID'];
|
|
147
|
-
options.connectionTimeout = options.connectionTimeout ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'CONNECT_TIMEOUT']);
|
|
148
|
-
options.authenticationTimeout = options.authenticationTimeout ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'AUTH_TIMEOUT']);
|
|
149
|
-
options.reauthenticationThreshold = options.reauthenticationThreshold ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'REAUTH_THRESHOLD']);
|
|
150
|
-
options.requestTimeout = options.requestTimeout ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'REQUEST_TIMEOUT']);
|
|
151
|
-
options.enforceRequestTimeout = options.enforceRequestTimeout ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'ENFORCE_REQUEST_TIMEOUT']);
|
|
152
|
-
const retries = (0, putil_varhelpers_1.toInt)(env[prefix + 'RETRIES']);
|
|
153
|
-
if (options.retry == null && retries) {
|
|
154
|
-
options.retry = {
|
|
155
|
-
maxRetryTime: (0, putil_varhelpers_1.toInt)(env[prefix + 'RETRY_MAX_TIME']),
|
|
156
|
-
initialRetryTime: (0, putil_varhelpers_1.toInt)(env[prefix + 'RETRY_INITIAL_TIME']),
|
|
157
|
-
retries,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
options.consumer = options.consumer || {};
|
|
161
|
-
options.consumer.groupId =
|
|
162
|
-
options.consumer.groupId ?? (env[prefix + 'CONSUMER_GROUP_ID'] || 'kafka_default_group');
|
|
163
|
-
return options;
|
|
164
|
-
}
|
|
165
107
|
/**
|
|
166
108
|
*
|
|
167
109
|
* @constructor
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { clone } from '@jsopen/objects';
|
|
3
|
+
import { toBoolean, toInt } from 'putil-varhelpers';
|
|
4
|
+
export function getConnectionOptions(moduleOptions, envPrefix = 'KAFKA_') {
|
|
5
|
+
const options = clone(moduleOptions);
|
|
6
|
+
const env = process.env;
|
|
7
|
+
options.brokers = options.brokers || (env[envPrefix + 'BROKERS'] ?? 'localhost').split(/\s*,\s*/);
|
|
8
|
+
if (options.ssl == null && toBoolean(env[envPrefix + 'SSL'])) {
|
|
9
|
+
options.ssl = {
|
|
10
|
+
ca: [env[envPrefix + 'SSL_CA_CERT'] || ''],
|
|
11
|
+
cert: env[envPrefix + 'SSL_CERT_FILE'],
|
|
12
|
+
key: env[envPrefix + 'SSL_KEY_FILE'],
|
|
13
|
+
passphrase: env[envPrefix + 'SSL_KEY_PASSPHRASE'],
|
|
14
|
+
rejectUnauthorized: toBoolean(env[envPrefix + 'SSL_REJECT_UNAUTHORIZED']),
|
|
15
|
+
checkServerIdentity: (host, cert) => {
|
|
16
|
+
if (cert.subject.CN !== host) {
|
|
17
|
+
return new Error(`Certificate CN (${cert.subject.CN}) does not match host (${host})`);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const sasl = env[envPrefix + 'SASL'];
|
|
23
|
+
if (options.sasl == null && sasl) {
|
|
24
|
+
if (sasl === 'plain' || sasl === 'scram-sha-256' || sasl === 'scram-sha-512') {
|
|
25
|
+
options.sasl = {
|
|
26
|
+
mechanism: sasl,
|
|
27
|
+
username: env[envPrefix + 'SASL_USERNAME'] || '',
|
|
28
|
+
password: env[envPrefix + 'SASL_PASSWORD'] || '',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else if (sasl === 'aws') {
|
|
32
|
+
options.sasl = {
|
|
33
|
+
mechanism: sasl,
|
|
34
|
+
authorizationIdentity: env[envPrefix + 'AWS_AUTH_IDENTITY'] || '',
|
|
35
|
+
accessKeyId: env[envPrefix + 'AWS_ACCESS_KEY_ID'] || '',
|
|
36
|
+
secretAccessKey: env[envPrefix + 'AWS_SECRET_ACCESS_KEY'] || '',
|
|
37
|
+
sessionToken: env[envPrefix + 'AWS_SESSION_TOKEN'],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
options.clientId = options.clientId ?? env[envPrefix + 'CLIENT_ID'];
|
|
42
|
+
options.connectionTimeout = options.connectionTimeout ?? toInt(env[envPrefix + 'CONNECT_TIMEOUT']);
|
|
43
|
+
options.authenticationTimeout = options.authenticationTimeout ?? toInt(env[envPrefix + 'AUTH_TIMEOUT']);
|
|
44
|
+
options.reauthenticationThreshold = options.reauthenticationThreshold ?? toInt(env[envPrefix + 'REAUTH_THRESHOLD']);
|
|
45
|
+
options.requestTimeout = options.requestTimeout ?? toInt(env[envPrefix + 'REQUEST_TIMEOUT']);
|
|
46
|
+
options.enforceRequestTimeout =
|
|
47
|
+
options.enforceRequestTimeout ?? toBoolean(env[envPrefix + 'ENFORCE_REQUEST_TIMEOUT']);
|
|
48
|
+
const retries = toInt(env[envPrefix + 'RETRIES']);
|
|
49
|
+
if (options.retry == null && retries) {
|
|
50
|
+
options.retry = {
|
|
51
|
+
maxRetryTime: toInt(env[envPrefix + 'RETRY_MAX_TIME']),
|
|
52
|
+
initialRetryTime: toInt(env[envPrefix + 'RETRY_INITIAL_TIME']),
|
|
53
|
+
retries,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
options.consumer = options.consumer || {};
|
|
57
|
+
options.consumer.groupId =
|
|
58
|
+
options.consumer.groupId ?? (env[envPrefix + 'CONSUMER_GROUP_ID'] || 'kafka_default_group');
|
|
59
|
+
return options;
|
|
60
|
+
}
|
package/esm/index.js
CHANGED
package/esm/kafka-core.module.js
CHANGED
|
@@ -2,21 +2,19 @@ var KafkaCoreModule_1;
|
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
3
|
import assert from 'node:assert';
|
|
4
4
|
import * as crypto from 'node:crypto';
|
|
5
|
-
import process from 'node:process';
|
|
6
|
-
import { clone } from '@jsopen/objects';
|
|
7
5
|
import { Inject, Logger } from '@nestjs/common';
|
|
8
6
|
import { ClientKafka, ClientsModule, Transport } from '@nestjs/microservices';
|
|
9
7
|
import * as colors from 'ansi-colors';
|
|
10
|
-
import { toBoolean, toInt } from 'putil-varhelpers';
|
|
11
8
|
import { KAFKA_CONNECTION_OPTIONS, KAFKA_MODULE_ID } from './constants.js';
|
|
12
9
|
import { createLogCreator } from './create-log-creator.js';
|
|
10
|
+
import { getConnectionOptions } from './get-connection-options.js';
|
|
13
11
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
14
12
|
let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
15
13
|
/**
|
|
16
14
|
*
|
|
17
15
|
*/
|
|
18
16
|
static forRoot(moduleOptions) {
|
|
19
|
-
const connectionOptions =
|
|
17
|
+
const connectionOptions = getConnectionOptions(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
20
18
|
return this._createDynamicModule(moduleOptions, {
|
|
21
19
|
global: moduleOptions.global,
|
|
22
20
|
providers: [
|
|
@@ -40,7 +38,7 @@ let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
|
40
38
|
inject: asyncOptions.inject,
|
|
41
39
|
useFactory: async (...args) => {
|
|
42
40
|
const opts = await asyncOptions.useFactory(...args);
|
|
43
|
-
return
|
|
41
|
+
return getConnectionOptions(opts, asyncOptions.envPrefix);
|
|
44
42
|
},
|
|
45
43
|
},
|
|
46
44
|
],
|
|
@@ -103,62 +101,6 @@ let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
|
103
101
|
exports,
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
|
-
static _readConnectionOptions(moduleOptions, prefix = 'KAFKA_') {
|
|
107
|
-
const options = clone(moduleOptions);
|
|
108
|
-
const env = process.env;
|
|
109
|
-
options.brokers = options.brokers || (env[prefix + 'URL'] ?? 'localhost').split(/\s*,\s*/);
|
|
110
|
-
if (options.ssl == null && toBoolean(env[prefix + 'SSL'])) {
|
|
111
|
-
options.ssl = {
|
|
112
|
-
ca: [env[prefix + 'SSL_CA_CERT'] || ''],
|
|
113
|
-
cert: env[prefix + 'SSL_CERT_FILE'],
|
|
114
|
-
key: env[prefix + 'SSL_KEY_FILE'],
|
|
115
|
-
passphrase: env[prefix + 'SSL_KEY_PASSPHRASE'],
|
|
116
|
-
rejectUnauthorized: toBoolean(env[prefix + 'SSL_REJECT_UNAUTHORIZED']),
|
|
117
|
-
checkServerIdentity: (host, cert) => {
|
|
118
|
-
if (cert.subject.CN !== host) {
|
|
119
|
-
return new Error(`Certificate CN (${cert.subject.CN}) does not match host (${host})`);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const sasl = env[prefix + 'SASL'];
|
|
125
|
-
if (options.sasl == null && sasl) {
|
|
126
|
-
if (sasl === 'plain' || sasl === 'scram-sha-256' || sasl === 'scram-sha-512') {
|
|
127
|
-
options.sasl = {
|
|
128
|
-
mechanism: sasl,
|
|
129
|
-
username: env[prefix + 'SASL_USERNAME'] || '',
|
|
130
|
-
password: env[prefix + 'SASL_PASSWORD'] || '',
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
else if (sasl === 'aws') {
|
|
134
|
-
options.sasl = {
|
|
135
|
-
mechanism: sasl,
|
|
136
|
-
authorizationIdentity: env[prefix + 'AWS_AUTH_IDENTITY'] || '',
|
|
137
|
-
accessKeyId: env[prefix + 'AWS_ACCESS_KEY_ID'] || '',
|
|
138
|
-
secretAccessKey: env[prefix + 'AWS_SECRET_ACCESS_KEY'] || '',
|
|
139
|
-
sessionToken: env[prefix + 'AWS_SESSION_TOKEN'],
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
options.clientId = options.clientId ?? env[prefix + 'CLIENT_ID'];
|
|
144
|
-
options.connectionTimeout = options.connectionTimeout ?? toInt(env[prefix + 'CONNECT_TIMEOUT']);
|
|
145
|
-
options.authenticationTimeout = options.authenticationTimeout ?? toInt(env[prefix + 'AUTH_TIMEOUT']);
|
|
146
|
-
options.reauthenticationThreshold = options.reauthenticationThreshold ?? toInt(env[prefix + 'REAUTH_THRESHOLD']);
|
|
147
|
-
options.requestTimeout = options.requestTimeout ?? toInt(env[prefix + 'REQUEST_TIMEOUT']);
|
|
148
|
-
options.enforceRequestTimeout = options.enforceRequestTimeout ?? toBoolean(env[prefix + 'ENFORCE_REQUEST_TIMEOUT']);
|
|
149
|
-
const retries = toInt(env[prefix + 'RETRIES']);
|
|
150
|
-
if (options.retry == null && retries) {
|
|
151
|
-
options.retry = {
|
|
152
|
-
maxRetryTime: toInt(env[prefix + 'RETRY_MAX_TIME']),
|
|
153
|
-
initialRetryTime: toInt(env[prefix + 'RETRY_INITIAL_TIME']),
|
|
154
|
-
retries,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
options.consumer = options.consumer || {};
|
|
158
|
-
options.consumer.groupId =
|
|
159
|
-
options.consumer.groupId ?? (env[prefix + 'CONSUMER_GROUP_ID'] || 'kafka_default_group');
|
|
160
|
-
return options;
|
|
161
|
-
}
|
|
162
104
|
/**
|
|
163
105
|
*
|
|
164
106
|
* @constructor
|
package/package.json
CHANGED
package/types/index.d.cts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export declare class KafkaCoreModule implements OnApplicationShutdown, OnApplica
|
|
|
14
14
|
*/
|
|
15
15
|
static forRootAsync(asyncOptions: KafkaModuleAsyncOptions): DynamicModule;
|
|
16
16
|
private static _createDynamicModule;
|
|
17
|
-
private static _readConnectionOptions;
|
|
18
17
|
/**
|
|
19
18
|
*
|
|
20
19
|
* @constructor
|