kafka-ts 1.0.2 → 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 +1 -0
- package/dist/broker.d.ts +1 -0
- package/dist/broker.js +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +2 -0
- package/dist/cluster.d.ts +1 -0
- package/dist/cluster.js +3 -1
- package/dist/connection.d.ts +1 -0
- package/dist/connection.js +1 -1
- package/dist/consumer/consumer.js +9 -3
- package/package.json +1 -1
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
package/dist/broker.js
CHANGED
package/dist/client.d.ts
CHANGED
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
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 =
|
|
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();
|
package/dist/connection.d.ts
CHANGED
package/dist/connection.js
CHANGED
|
@@ -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
|
-
},
|
|
108
|
+
}, this.options.requestTimeout);
|
|
109
109
|
try {
|
|
110
110
|
this.queue[correlationId] = { resolve, reject };
|
|
111
111
|
await this.write(requestEncoder.value());
|
|
@@ -48,7 +48,7 @@ class Consumer extends events_1.default {
|
|
|
48
48
|
minBytes: options.minBytes ?? 1,
|
|
49
49
|
maxBytes: options.maxBytes ?? 1_048_576,
|
|
50
50
|
partitionMaxBytes: options.partitionMaxBytes ?? 1_048_576,
|
|
51
|
-
isolationLevel: options.isolationLevel ??
|
|
51
|
+
isolationLevel: options.isolationLevel ?? 1 /* IsolationLevel.READ_COMMITTED */,
|
|
52
52
|
allowTopicAutoCreation: options.allowTopicAutoCreation ?? false,
|
|
53
53
|
fromBeginning: options.fromBeginning ?? false,
|
|
54
54
|
fromTimestamp: options.fromTimestamp ?? (options.fromBeginning ? -2n : -1n),
|
|
@@ -186,7 +186,13 @@ class Consumer extends events_1.default {
|
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
188
|
await retrier(() => options.onBatch(messages));
|
|
189
|
-
|
|
189
|
+
response.responses.forEach(({ topicId, partitions }) => {
|
|
190
|
+
partitions.forEach(({ partitionIndex, records }) => {
|
|
191
|
+
records.forEach(({ baseOffset, lastOffsetDelta }) => {
|
|
192
|
+
this.offsetManager.resolve(this.metadata.getTopicNameById(topicId), partitionIndex, baseOffset + BigInt(lastOffsetDelta) + 1n);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
190
196
|
await this.consumerGroup?.offsetCommit(topicPartitions);
|
|
191
197
|
this.offsetManager.flush(topicPartitions);
|
|
192
198
|
}
|
|
@@ -207,7 +213,7 @@ class Consumer extends events_1.default {
|
|
|
207
213
|
currentLeaderEpoch: -1,
|
|
208
214
|
fetchOffset: this.offsetManager.getCurrentOffset(topic, partition),
|
|
209
215
|
lastFetchedEpoch: -1,
|
|
210
|
-
logStartOffset:
|
|
216
|
+
logStartOffset: -1n,
|
|
211
217
|
partitionMaxBytes,
|
|
212
218
|
})),
|
|
213
219
|
})),
|