kafka-ts 0.0.6-beta.6 → 0.0.6-beta.8
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/dist/connection.js +1 -1
- package/dist/utils/encoder.js +4 -4
- 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);
|
package/dist/connection.js
CHANGED
|
@@ -130,7 +130,7 @@ class Connection {
|
|
|
130
130
|
write(buffer) {
|
|
131
131
|
return new Promise((resolve, reject) => {
|
|
132
132
|
const { stack } = new Error('Write error');
|
|
133
|
-
this.socket.write(buffer, (error) => {
|
|
133
|
+
this.socket.write(buffer, 'binary', (error) => {
|
|
134
134
|
if (error) {
|
|
135
135
|
const err = new error_1.ConnectionError(error.message);
|
|
136
136
|
err.stack += `\n${stack}`;
|
package/dist/utils/encoder.js
CHANGED
|
@@ -43,7 +43,7 @@ class Encoder {
|
|
|
43
43
|
}
|
|
44
44
|
writeUVarInt(value) {
|
|
45
45
|
const byteArray = [];
|
|
46
|
-
while ((value &
|
|
46
|
+
while ((value & 0xffffff80) !== 0) {
|
|
47
47
|
byteArray.push((value & 0x7f) | 0x80);
|
|
48
48
|
value >>>= 7;
|
|
49
49
|
}
|
|
@@ -56,11 +56,11 @@ class Encoder {
|
|
|
56
56
|
}
|
|
57
57
|
writeUVarLong(value) {
|
|
58
58
|
const byteArray = [];
|
|
59
|
-
while ((value &
|
|
59
|
+
while ((value & 0xffffffffffffff80n) !== 0n) {
|
|
60
60
|
byteArray.push(Number((value & BigInt(0x7f)) | BigInt(0x80)));
|
|
61
|
-
value
|
|
61
|
+
value >>= 7n;
|
|
62
62
|
}
|
|
63
|
-
byteArray.push(Number(value));
|
|
63
|
+
byteArray.push(Number(value & BigInt(0x7f)));
|
|
64
64
|
return this.write(Buffer.from(byteArray));
|
|
65
65
|
}
|
|
66
66
|
writeVarLong(value) {
|