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.
Files changed (2) hide show
  1. package/dist/cluster.js +9 -3
  2. 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 = new broker_1.Broker({ clientId: null, sasl: null, ssl: null, options: { port: 9092 } });
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([this.seedBroker.disconnect(), ...Object.values(this.brokerById).map((x) => x.disconnect())]);
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.disconnect();
39
+ await this.seedBroker?.disconnect();
34
40
  this.seedBroker = await this.acquireBroker(nodeId);
35
41
  };
36
42
  sendRequest = (...args) => this.seedBroker.sendRequest(...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-ts",
3
- "version": "0.0.6-beta.6",
3
+ "version": "0.0.6-beta.7",
4
4
  "main": "dist/index.js",
5
5
  "author": "Priit Käärd",
6
6
  "license": "MIT",