kafka-ts 0.0.6-beta.6 → 0.0.6-beta.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/cluster.js +9 -3
- package/package.json +1 -1
package/dist/cluster.js
CHANGED
|
@@ -7,7 +7,7 @@ const error_1 = require("./utils/error");
|
|
|
7
7
|
const logger_1 = require("./utils/logger");
|
|
8
8
|
class Cluster {
|
|
9
9
|
options;
|
|
10
|
-
seedBroker
|
|
10
|
+
seedBroker;
|
|
11
11
|
brokerById = {};
|
|
12
12
|
brokerMetadata = {};
|
|
13
13
|
constructor(options) {
|
|
@@ -24,13 +24,19 @@ class Cluster {
|
|
|
24
24
|
this.brokerMetadata = Object.fromEntries(metadata.brokers.map((options) => [options.nodeId, options]));
|
|
25
25
|
}
|
|
26
26
|
async ensureConnected() {
|
|
27
|
+
if (!this.seedBroker) {
|
|
28
|
+
return this.connect();
|
|
29
|
+
}
|
|
27
30
|
await Promise.all([this.seedBroker, ...Object.values(this.brokerById)].map((x) => x.ensureConnected()));
|
|
28
31
|
}
|
|
29
32
|
async disconnect() {
|
|
30
|
-
await Promise.all([
|
|
33
|
+
await Promise.all([
|
|
34
|
+
this.seedBroker?.disconnect(),
|
|
35
|
+
...Object.values(this.brokerById).map((x) => x.disconnect()),
|
|
36
|
+
]);
|
|
31
37
|
}
|
|
32
38
|
setSeedBroker = async (nodeId) => {
|
|
33
|
-
await this.seedBroker
|
|
39
|
+
await this.seedBroker?.disconnect();
|
|
34
40
|
this.seedBroker = await this.acquireBroker(nodeId);
|
|
35
41
|
};
|
|
36
42
|
sendRequest = (...args) => this.seedBroker.sendRequest(...args);
|