kafka-ts 1.0.3 → 1.1.0

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 CHANGED
@@ -141,6 +141,7 @@ The existing high-level libraries (e.g. kafkajs) are missing a few crucial featu
141
141
  | bootstrapServers | TcpSocketConnectOpts[] | true | | List of kafka brokers for initial cluster discovery. |
142
142
  | sasl | SASLProvider | false | | SASL provider |
143
143
  | ssl | TLSSocketOptions | false | | SSL configuration. |
144
+ | requestTimeout | number | false | 60000 | Request timeout in milliseconds. |
144
145
 
145
146
  #### Supported SASL mechanisms
146
147
 
package/dist/broker.d.ts CHANGED
@@ -14,6 +14,7 @@ type BrokerOptions = {
14
14
  options: TcpSocketConnectOpts;
15
15
  sasl: SASLProvider | null;
16
16
  ssl: TLSSocketOptions | null;
17
+ requestTimeout: number;
17
18
  };
18
19
  export declare class Broker {
19
20
  private options;
package/dist/broker.js CHANGED
@@ -14,6 +14,7 @@ class Broker {
14
14
  clientId: this.options.clientId,
15
15
  connection: this.options.options,
16
16
  ssl: this.options.ssl,
17
+ requestTimeout: this.options.requestTimeout,
17
18
  });
18
19
  this.sendRequest = this.connection.sendRequest.bind(this.connection);
19
20
  }
package/dist/client.d.ts CHANGED
@@ -11,6 +11,7 @@ export type ClientOptions = {
11
11
  bootstrapServers: TcpSocketConnectOpts[];
12
12
  sasl?: SASLProvider | null;
13
13
  ssl?: TLSSocketOptions | null;
14
+ requestTimeout?: number;
14
15
  };
15
16
  export declare class Client {
16
17
  private options;
package/dist/client.js CHANGED
@@ -12,6 +12,7 @@ class Client {
12
12
  clientId: options.clientId ?? null,
13
13
  sasl: options.sasl ?? null,
14
14
  ssl: options.ssl ?? null,
15
+ requestTimeout: options.requestTimeout ?? 60_000,
15
16
  };
16
17
  }
17
18
  async startConsumer(options) {
@@ -28,6 +29,7 @@ class Client {
28
29
  bootstrapServers: this.options.bootstrapServers,
29
30
  sasl: this.options.sasl,
30
31
  ssl: this.options.ssl,
32
+ requestTimeout: this.options.requestTimeout,
31
33
  });
32
34
  }
33
35
  }
package/dist/cluster.d.ts CHANGED
@@ -9,6 +9,7 @@ type ClusterOptions = {
9
9
  bootstrapServers: TcpSocketConnectOpts[];
10
10
  sasl: SASLProvider | null;
11
11
  ssl: TLSSocketOptions | null;
12
+ requestTimeout: number;
12
13
  };
13
14
  export declare class Cluster {
14
15
  private options;
package/dist/cluster.js CHANGED
@@ -54,6 +54,7 @@ class Cluster {
54
54
  clientId: this.options.clientId,
55
55
  sasl: this.options.sasl,
56
56
  ssl: this.options.ssl,
57
+ requestTimeout: this.options.requestTimeout,
57
58
  options: this.brokerMetadata[nodeId],
58
59
  });
59
60
  await broker.connect();
@@ -63,10 +64,11 @@ class Cluster {
63
64
  const randomizedBrokers = this.options.bootstrapServers.toSorted(() => Math.random() - 0.5);
64
65
  for (const options of randomizedBrokers) {
65
66
  try {
66
- const broker = await new broker_1.Broker({
67
+ const broker = new broker_1.Broker({
67
68
  clientId: this.options.clientId,
68
69
  sasl: this.options.sasl,
69
70
  ssl: this.options.ssl,
71
+ requestTimeout: this.options.requestTimeout,
70
72
  options,
71
73
  });
72
74
  await broker.connect();
@@ -7,6 +7,7 @@ type ConnectionOptions = {
7
7
  clientId: string | null;
8
8
  connection: TcpSocketConnectOpts;
9
9
  ssl: TLSSocketOptions | null;
10
+ requestTimeout: number;
10
11
  };
11
12
  export declare class Connection {
12
13
  private options;
@@ -105,7 +105,7 @@ class Connection {
105
105
  timeout = setTimeout(() => {
106
106
  delete this.queue[correlationId];
107
107
  reject(new error_1.ConnectionError(`${apiName} timed out`));
108
- }, 30_000);
108
+ }, this.options.requestTimeout);
109
109
  try {
110
110
  this.queue[correlationId] = { resolve, reject };
111
111
  await this.write(requestEncoder.value());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-ts",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "author": "Priit Käärd",
6
6
  "license": "MIT",