@platformatic/kafka 1.0.0 → 1.2.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/apis/admin/index.d.ts +38 -37
- package/dist/apis/admin/index.js +38 -37
- package/dist/apis/admin/list-groups-v4.d.ts +17 -0
- package/dist/apis/admin/list-groups-v4.js +40 -0
- package/dist/apis/consumer/fetch-v16.js +121 -0
- package/dist/apis/consumer/fetch-v17.d.ts +46 -0
- package/dist/apis/consumer/index.d.ts +11 -9
- package/dist/apis/consumer/index.js +11 -9
- package/dist/apis/consumer/list-offsets-v8.js +68 -0
- package/dist/apis/consumer/list-offsets-v9.d.ts +30 -0
- package/dist/apis/definitions.js +0 -1
- package/dist/apis/metadata/api-versions-v3.js +41 -0
- package/dist/apis/metadata/api-versions-v4.d.ts +17 -0
- package/dist/apis/metadata/find-coordinator-v4.js +50 -0
- package/dist/apis/metadata/find-coordinator-v5.d.ts +19 -0
- package/dist/apis/metadata/find-coordinator-v5.js +50 -0
- package/dist/apis/metadata/find-coordinator-v6.d.ts +19 -0
- package/dist/apis/metadata/index.d.ts +6 -3
- package/dist/apis/metadata/index.js +6 -3
- package/dist/apis/producer/index.d.ts +8 -6
- package/dist/apis/producer/index.js +8 -6
- package/dist/apis/producer/init-producer-id-v4.js +38 -0
- package/dist/apis/producer/init-producer-id-v5.d.ts +21 -0
- package/dist/apis/producer/produce-v10.js +104 -0
- package/dist/apis/producer/produce-v11.d.ts +29 -0
- package/dist/apis/security/index.d.ts +2 -2
- package/dist/apis/security/index.js +2 -2
- package/dist/apis/telemetry/index.d.ts +3 -3
- package/dist/apis/telemetry/index.js +3 -3
- package/dist/clients/admin/admin.js +58 -22
- package/dist/clients/base/base.d.ts +19 -3
- package/dist/clients/base/base.js +93 -13
- package/dist/clients/base/options.d.ts +2 -0
- package/dist/clients/base/options.js +5 -0
- package/dist/clients/callbacks.d.ts +1 -0
- package/dist/clients/callbacks.js +3 -2
- package/dist/clients/consumer/consumer.d.ts +1 -1
- package/dist/clients/consumer/consumer.js +166 -105
- package/dist/clients/consumer/messages-stream.d.ts +1 -0
- package/dist/clients/consumer/messages-stream.js +81 -47
- package/dist/clients/consumer/options.d.ts +3 -0
- package/dist/clients/consumer/options.js +1 -0
- package/dist/clients/consumer/types.d.ts +8 -3
- package/dist/clients/producer/producer.js +49 -28
- package/dist/diagnostic.d.ts +47 -0
- package/dist/diagnostic.js +38 -0
- package/dist/errors.d.ts +5 -1
- package/dist/errors.js +12 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/network/connection-pool.d.ts +2 -1
- package/dist/network/connection-pool.js +36 -25
- package/dist/network/connection.d.ts +2 -2
- package/dist/network/connection.js +135 -81
- package/dist/protocol/compression.js +8 -8
- package/dist/protocol/reader.js +0 -1
- package/dist/protocol/records.js +0 -3
- package/dist/protocol/sasl/plain.d.ts +1 -1
- package/dist/protocol/sasl/scram-sha.d.ts +11 -4
- package/dist/protocol/sasl/scram-sha.js +8 -2
- package/dist/symbols.d.ts +1 -0
- package/dist/symbols.js +2 -0
- package/package.json +3 -3
- /package/dist/apis/admin/{alter-client-quotas.d.ts → alter-client-quotas-v1.d.ts} +0 -0
- /package/dist/apis/admin/{alter-client-quotas.js → alter-client-quotas-v1.js} +0 -0
- /package/dist/apis/admin/{alter-configs.d.ts → alter-configs-v2.d.ts} +0 -0
- /package/dist/apis/admin/{alter-configs.js → alter-configs-v2.js} +0 -0
- /package/dist/apis/admin/{alter-partition-reassignments.d.ts → alter-partition-reassignments-v0.d.ts} +0 -0
- /package/dist/apis/admin/{alter-partition-reassignments.js → alter-partition-reassignments-v0.js} +0 -0
- /package/dist/apis/admin/{alter-partition.d.ts → alter-partition-v3.d.ts} +0 -0
- /package/dist/apis/admin/{alter-partition.js → alter-partition-v3.js} +0 -0
- /package/dist/apis/admin/{alter-replica-log-dirs.d.ts → alter-replica-log-dirs-v2.d.ts} +0 -0
- /package/dist/apis/admin/{alter-replica-log-dirs.js → alter-replica-log-dirs-v2.js} +0 -0
- /package/dist/apis/admin/{alter-user-scram-credentials.d.ts → alter-user-scram-credentials-v0.d.ts} +0 -0
- /package/dist/apis/admin/{alter-user-scram-credentials.js → alter-user-scram-credentials-v0.js} +0 -0
- /package/dist/apis/admin/{consumer-group-describe.d.ts → consumer-group-describe-v0.d.ts} +0 -0
- /package/dist/apis/admin/{consumer-group-describe.js → consumer-group-describe-v0.js} +0 -0
- /package/dist/apis/admin/{create-acls.d.ts → create-acls-v3.d.ts} +0 -0
- /package/dist/apis/admin/{create-acls.js → create-acls-v3.js} +0 -0
- /package/dist/apis/admin/{create-delegation-token.d.ts → create-delegation-token-v3.d.ts} +0 -0
- /package/dist/apis/admin/{create-delegation-token.js → create-delegation-token-v3.js} +0 -0
- /package/dist/apis/admin/{create-partitions.d.ts → create-partitions-v3.d.ts} +0 -0
- /package/dist/apis/admin/{create-partitions.js → create-partitions-v3.js} +0 -0
- /package/dist/apis/admin/{create-topics.d.ts → create-topics-v7.d.ts} +0 -0
- /package/dist/apis/admin/{create-topics.js → create-topics-v7.js} +0 -0
- /package/dist/apis/admin/{delete-acls.d.ts → delete-acls-v3.d.ts} +0 -0
- /package/dist/apis/admin/{delete-acls.js → delete-acls-v3.js} +0 -0
- /package/dist/apis/admin/{delete-groups.d.ts → delete-groups-v2.d.ts} +0 -0
- /package/dist/apis/admin/{delete-groups.js → delete-groups-v2.js} +0 -0
- /package/dist/apis/admin/{delete-records.d.ts → delete-records-v2.d.ts} +0 -0
- /package/dist/apis/admin/{delete-records.js → delete-records-v2.js} +0 -0
- /package/dist/apis/admin/{delete-topics.d.ts → delete-topics-v6.d.ts} +0 -0
- /package/dist/apis/admin/{delete-topics.js → delete-topics-v6.js} +0 -0
- /package/dist/apis/admin/{describe-acls.d.ts → describe-acls-v3.d.ts} +0 -0
- /package/dist/apis/admin/{describe-acls.js → describe-acls-v3.js} +0 -0
- /package/dist/apis/admin/{describe-client-quotas.d.ts → describe-client-quotas-v0.d.ts} +0 -0
- /package/dist/apis/admin/{describe-client-quotas.js → describe-client-quotas-v0.js} +0 -0
- /package/dist/apis/admin/{describe-cluster.d.ts → describe-cluster-v1.d.ts} +0 -0
- /package/dist/apis/admin/{describe-cluster.js → describe-cluster-v1.js} +0 -0
- /package/dist/apis/admin/{describe-configs.d.ts → describe-configs-v4.d.ts} +0 -0
- /package/dist/apis/admin/{describe-configs.js → describe-configs-v4.js} +0 -0
- /package/dist/apis/admin/{describe-delegation-token.d.ts → describe-delegation-token-v3.d.ts} +0 -0
- /package/dist/apis/admin/{describe-delegation-token.js → describe-delegation-token-v3.js} +0 -0
- /package/dist/apis/admin/{describe-groups.d.ts → describe-groups-v5.d.ts} +0 -0
- /package/dist/apis/admin/{describe-groups.js → describe-groups-v5.js} +0 -0
- /package/dist/apis/admin/{describe-log-dirs.d.ts → describe-log-dirs-v4.d.ts} +0 -0
- /package/dist/apis/admin/{describe-log-dirs.js → describe-log-dirs-v4.js} +0 -0
- /package/dist/apis/admin/{describe-producers.d.ts → describe-producers-v0.d.ts} +0 -0
- /package/dist/apis/admin/{describe-producers.js → describe-producers-v0.js} +0 -0
- /package/dist/apis/admin/{describe-quorum.d.ts → describe-quorum-v2.d.ts} +0 -0
- /package/dist/apis/admin/{describe-quorum.js → describe-quorum-v2.js} +0 -0
- /package/dist/apis/admin/{describe-topic-partitions.d.ts → describe-topic-partitions-v0.d.ts} +0 -0
- /package/dist/apis/admin/{describe-topic-partitions.js → describe-topic-partitions-v0.js} +0 -0
- /package/dist/apis/admin/{describe-transactions.d.ts → describe-transactions-v0.d.ts} +0 -0
- /package/dist/apis/admin/{describe-transactions.js → describe-transactions-v0.js} +0 -0
- /package/dist/apis/admin/{describe-user-scram-credentials.d.ts → describe-user-scram-credentials-v0.d.ts} +0 -0
- /package/dist/apis/admin/{describe-user-scram-credentials.js → describe-user-scram-credentials-v0.js} +0 -0
- /package/dist/apis/admin/{envelope.d.ts → envelope-v0.d.ts} +0 -0
- /package/dist/apis/admin/{envelope.js → envelope-v0.js} +0 -0
- /package/dist/apis/admin/{expire-delegation-token.d.ts → expire-delegation-token-v2.d.ts} +0 -0
- /package/dist/apis/admin/{expire-delegation-token.js → expire-delegation-token-v2.js} +0 -0
- /package/dist/apis/admin/{incremental-alter-configs.d.ts → incremental-alter-configs-v1.d.ts} +0 -0
- /package/dist/apis/admin/{incremental-alter-configs.js → incremental-alter-configs-v1.js} +0 -0
- /package/dist/apis/admin/{list-groups.d.ts → list-groups-v5.d.ts} +0 -0
- /package/dist/apis/admin/{list-groups.js → list-groups-v5.js} +0 -0
- /package/dist/apis/admin/{list-partition-reassignments.d.ts → list-partition-reassignments-v0.d.ts} +0 -0
- /package/dist/apis/admin/{list-partition-reassignments.js → list-partition-reassignments-v0.js} +0 -0
- /package/dist/apis/admin/{list-transactions.d.ts → list-transactions-v1.d.ts} +0 -0
- /package/dist/apis/admin/{list-transactions.js → list-transactions-v1.js} +0 -0
- /package/dist/apis/admin/{offset-delete.d.ts → offset-delete-v0.d.ts} +0 -0
- /package/dist/apis/admin/{offset-delete.js → offset-delete-v0.js} +0 -0
- /package/dist/apis/admin/{renew-delegation-token.d.ts → renew-delegation-token-v2.d.ts} +0 -0
- /package/dist/apis/admin/{renew-delegation-token.js → renew-delegation-token-v2.js} +0 -0
- /package/dist/apis/admin/{unregister-broker.d.ts → unregister-broker-v0.d.ts} +0 -0
- /package/dist/apis/admin/{unregister-broker.js → unregister-broker-v0.js} +0 -0
- /package/dist/apis/admin/{update-features.d.ts → update-features-v1.d.ts} +0 -0
- /package/dist/apis/admin/{update-features.js → update-features-v1.js} +0 -0
- /package/dist/apis/consumer/{consumer-group-heartbeat.d.ts → consumer-group-heartbeat-v0.d.ts} +0 -0
- /package/dist/apis/consumer/{consumer-group-heartbeat.js → consumer-group-heartbeat-v0.js} +0 -0
- /package/dist/apis/consumer/{fetch.d.ts → fetch-v16.d.ts} +0 -0
- /package/dist/apis/consumer/{fetch.js → fetch-v17.js} +0 -0
- /package/dist/apis/consumer/{heartbeat.d.ts → heartbeat-v4.d.ts} +0 -0
- /package/dist/apis/consumer/{heartbeat.js → heartbeat-v4.js} +0 -0
- /package/dist/apis/consumer/{join-group.d.ts → join-group-v9.d.ts} +0 -0
- /package/dist/apis/consumer/{join-group.js → join-group-v9.js} +0 -0
- /package/dist/apis/consumer/{leave-group.d.ts → leave-group-v5.d.ts} +0 -0
- /package/dist/apis/consumer/{leave-group.js → leave-group-v5.js} +0 -0
- /package/dist/apis/consumer/{list-offsets.d.ts → list-offsets-v8.d.ts} +0 -0
- /package/dist/apis/consumer/{list-offsets.js → list-offsets-v9.js} +0 -0
- /package/dist/apis/consumer/{offset-commit.d.ts → offset-commit-v9.d.ts} +0 -0
- /package/dist/apis/consumer/{offset-commit.js → offset-commit-v9.js} +0 -0
- /package/dist/apis/consumer/{offset-fetch.d.ts → offset-fetch-v9.d.ts} +0 -0
- /package/dist/apis/consumer/{offset-fetch.js → offset-fetch-v9.js} +0 -0
- /package/dist/apis/consumer/{sync-group.d.ts → sync-group-v5.d.ts} +0 -0
- /package/dist/apis/consumer/{sync-group.js → sync-group-v5.js} +0 -0
- /package/dist/apis/metadata/{api-versions.d.ts → api-versions-v3.d.ts} +0 -0
- /package/dist/apis/metadata/{api-versions.js → api-versions-v4.js} +0 -0
- /package/dist/apis/metadata/{find-coordinator.d.ts → find-coordinator-v4.d.ts} +0 -0
- /package/dist/apis/metadata/{find-coordinator.js → find-coordinator-v6.js} +0 -0
- /package/dist/apis/metadata/{metadata.d.ts → metadata-v12.d.ts} +0 -0
- /package/dist/apis/metadata/{metadata.js → metadata-v12.js} +0 -0
- /package/dist/apis/producer/{add-offsets-to-txn.d.ts → add-offsets-to-txn-v4.d.ts} +0 -0
- /package/dist/apis/producer/{add-offsets-to-txn.js → add-offsets-to-txn-v4.js} +0 -0
- /package/dist/apis/producer/{add-partitions-to-txn.d.ts → add-partitions-to-txn-v5.d.ts} +0 -0
- /package/dist/apis/producer/{add-partitions-to-txn.js → add-partitions-to-txn-v5.js} +0 -0
- /package/dist/apis/producer/{end-txn.d.ts → end-txn-v4.d.ts} +0 -0
- /package/dist/apis/producer/{end-txn.js → end-txn-v4.js} +0 -0
- /package/dist/apis/producer/{init-producer-id.d.ts → init-producer-id-v4.d.ts} +0 -0
- /package/dist/apis/producer/{init-producer-id.js → init-producer-id-v5.js} +0 -0
- /package/dist/apis/producer/{produce.d.ts → produce-v10.d.ts} +0 -0
- /package/dist/apis/producer/{produce.js → produce-v11.js} +0 -0
- /package/dist/apis/producer/{txn-offset-commit.d.ts → txn-offset-commit-v4.d.ts} +0 -0
- /package/dist/apis/producer/{txn-offset-commit.js → txn-offset-commit-v4.js} +0 -0
- /package/dist/apis/security/{sasl-authenticate.d.ts → sasl-authenticate-v2.d.ts} +0 -0
- /package/dist/apis/security/{sasl-authenticate.js → sasl-authenticate-v2.js} +0 -0
- /package/dist/apis/security/{sasl-handshake.d.ts → sasl-handshake-v1.d.ts} +0 -0
- /package/dist/apis/security/{sasl-handshake.js → sasl-handshake-v1.js} +0 -0
- /package/dist/apis/telemetry/{get-telemetry-subscriptions.d.ts → get-telemetry-subscriptions-v0.d.ts} +0 -0
- /package/dist/apis/telemetry/{get-telemetry-subscriptions.js → get-telemetry-subscriptions-v0.js} +0 -0
- /package/dist/apis/telemetry/{list-client-metrics-resources.d.ts → list-client-metrics-resources-v0.d.ts} +0 -0
- /package/dist/apis/telemetry/{list-client-metrics-resources.js → list-client-metrics-resources-v0.js} +0 -0
- /package/dist/apis/telemetry/{push-telemetry.d.ts → push-telemetry-v0.d.ts} +0 -0
- /package/dist/apis/telemetry/{push-telemetry.js → push-telemetry-v0.js} +0 -0
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { api as fetchV17 } from "../../apis/consumer/fetch.js";
|
|
2
|
-
import { api as heartbeatV4 } from "../../apis/consumer/heartbeat.js";
|
|
3
|
-
import { api as joinGroupV9 } from "../../apis/consumer/join-group.js";
|
|
4
|
-
import { api as leaveGroupV5 } from "../../apis/consumer/leave-group.js";
|
|
5
|
-
import { api as listOffsetsV9 } from "../../apis/consumer/list-offsets.js";
|
|
6
|
-
import { api as offsetCommitV9 } from "../../apis/consumer/offset-commit.js";
|
|
7
|
-
import { api as offsetFetchV9 } from "../../apis/consumer/offset-fetch.js";
|
|
8
|
-
import { api as syncGroupV5 } from "../../apis/consumer/sync-group.js";
|
|
9
1
|
import { FetchIsolationLevels, FindCoordinatorKeyTypes } from "../../apis/enumerations.js";
|
|
10
|
-
import {
|
|
2
|
+
import { consumerCommitsChannel, consumerConsumesChannel, consumerFetchesChannel, consumerGroupChannel, consumerHeartbeatChannel, consumerOffsetsChannel, createDiagnosticContext } from "../../diagnostic.js";
|
|
11
3
|
import { UserError } from "../../errors.js";
|
|
12
4
|
import { Reader } from "../../protocol/reader.js";
|
|
13
5
|
import { Writer } from "../../protocol/writer.js";
|
|
14
|
-
import { Base, kBootstrapBrokers, kCheckNotClosed, kClosed, kConnections, kCreateConnectionPool, kFetchConnections, kFormatValidationErrors, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kPrometheus, kValidateOptions } from "../base/base.js";
|
|
6
|
+
import { Base, kAfterCreate, kBootstrapBrokers, kCheckNotClosed, kClosed, kConnections, kCreateConnectionPool, kFetchConnections, kFormatValidationErrors, kGetApi, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kPrometheus, kValidateOptions } from "../base/base.js";
|
|
15
7
|
import { defaultBaseOptions } from "../base/options.js";
|
|
16
8
|
import { createPromisifiedCallback, kCallbackPromise, runConcurrentCallbacks } from "../callbacks.js";
|
|
17
9
|
import { ensureMetric } from "../metrics.js";
|
|
@@ -72,6 +64,7 @@ export class Consumer extends Base {
|
|
|
72
64
|
this.#metricActiveStreams = ensureMetric(this[kPrometheus], 'Gauge', 'kafka_consumers_streams', 'Number of active Kafka consumers streams');
|
|
73
65
|
this.topics.setMetric(ensureMetric(this[kPrometheus], 'Gauge', 'kafka_consumers_topics', 'Number of topics being consumed'));
|
|
74
66
|
}
|
|
67
|
+
this[kAfterCreate]('consumer');
|
|
75
68
|
}
|
|
76
69
|
get streamsCount() {
|
|
77
70
|
return this.#streams.size;
|
|
@@ -153,7 +146,7 @@ export class Consumer extends Base {
|
|
|
153
146
|
callback(validationError, undefined);
|
|
154
147
|
return callback[kCallbackPromise];
|
|
155
148
|
}
|
|
156
|
-
this.#fetch(options, callback);
|
|
149
|
+
consumerFetchesChannel.traceCallback(this.#fetch, 1, createDiagnosticContext({ client: this, operation: 'fetch', options }), this, options, callback);
|
|
157
150
|
return callback[kCallbackPromise];
|
|
158
151
|
}
|
|
159
152
|
commit(options, callback) {
|
|
@@ -168,7 +161,7 @@ export class Consumer extends Base {
|
|
|
168
161
|
callback(validationError);
|
|
169
162
|
return callback[kCallbackPromise];
|
|
170
163
|
}
|
|
171
|
-
this.#commit(options, callback);
|
|
164
|
+
consumerCommitsChannel.traceCallback(this.#commit, 1, createDiagnosticContext({ client: this, operation: 'commit', options }), this, options, callback);
|
|
172
165
|
return callback[kCallbackPromise];
|
|
173
166
|
}
|
|
174
167
|
listOffsets(options, callback) {
|
|
@@ -183,7 +176,7 @@ export class Consumer extends Base {
|
|
|
183
176
|
callback(validationError, undefined);
|
|
184
177
|
return callback[kCallbackPromise];
|
|
185
178
|
}
|
|
186
|
-
this.#listOffsets(options, callback);
|
|
179
|
+
consumerOffsetsChannel.traceCallback(this.#listOffsets, 1, createDiagnosticContext({ client: this, operation: 'listOffsets', options }), this, options, callback);
|
|
187
180
|
return callback[kCallbackPromise];
|
|
188
181
|
}
|
|
189
182
|
listCommittedOffsets(options, callback) {
|
|
@@ -198,7 +191,7 @@ export class Consumer extends Base {
|
|
|
198
191
|
callback(validationError, undefined);
|
|
199
192
|
return callback[kCallbackPromise];
|
|
200
193
|
}
|
|
201
|
-
this.#listCommittedOffsets(options, callback);
|
|
194
|
+
consumerOffsetsChannel.traceCallback(this.#listCommittedOffsets, 1, createDiagnosticContext({ client: this, operation: 'listCommittedOffsets', options }), this, options, callback);
|
|
202
195
|
return callback[kCallbackPromise];
|
|
203
196
|
}
|
|
204
197
|
findGroupCoordinator(callback) {
|
|
@@ -258,37 +251,8 @@ export class Consumer extends Base {
|
|
|
258
251
|
});
|
|
259
252
|
return callback[kCallbackPromise];
|
|
260
253
|
}
|
|
261
|
-
#consume(options, callback
|
|
262
|
-
|
|
263
|
-
let joinNeeded = this.memberId === null;
|
|
264
|
-
if (trackTopics) {
|
|
265
|
-
for (const topic of options.topics) {
|
|
266
|
-
if (this.topics.track(topic)) {
|
|
267
|
-
joinNeeded = true;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// If we need to (re)join the group, do that first and then try again
|
|
272
|
-
if (joinNeeded) {
|
|
273
|
-
this.joinGroup(options, error => {
|
|
274
|
-
if (error) {
|
|
275
|
-
callback(error, undefined);
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
this.#consume(options, callback, false);
|
|
279
|
-
});
|
|
280
|
-
return callback[kCallbackPromise];
|
|
281
|
-
}
|
|
282
|
-
// Create the stream and start consuming
|
|
283
|
-
const stream = new MessagesStream(this, options);
|
|
284
|
-
this.#streams.add(stream);
|
|
285
|
-
this.#metricActiveStreams?.inc();
|
|
286
|
-
stream.once('close', () => {
|
|
287
|
-
this.#metricActiveStreams?.dec();
|
|
288
|
-
this.#streams.delete(stream);
|
|
289
|
-
});
|
|
290
|
-
callback(null, stream);
|
|
291
|
-
return callback[kCallbackPromise];
|
|
254
|
+
#consume(options, callback) {
|
|
255
|
+
consumerConsumesChannel.traceCallback(this.#performConsume, 2, createDiagnosticContext({ client: this, operation: 'consume', options }), this, options, true, callback);
|
|
292
256
|
}
|
|
293
257
|
#fetch(options, callback) {
|
|
294
258
|
this[kPerformWithRetry]('fetch', retryCallback => {
|
|
@@ -307,7 +271,13 @@ export class Consumer extends Base {
|
|
|
307
271
|
retryCallback(error, undefined);
|
|
308
272
|
return;
|
|
309
273
|
}
|
|
310
|
-
|
|
274
|
+
this[kGetApi]('Fetch', (error, api) => {
|
|
275
|
+
if (error) {
|
|
276
|
+
retryCallback(error, undefined);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
api(connection, options.maxWaitTime ?? this[kOptions].maxWaitTime, options.minBytes ?? this[kOptions].minBytes, options.maxBytes ?? this[kOptions].maxBytes, FetchIsolationLevels[options.isolationLevel ?? this[kOptions].isolationLevel], 0, 0, options.topics, [], '', retryCallback);
|
|
280
|
+
});
|
|
311
281
|
});
|
|
312
282
|
});
|
|
313
283
|
}, callback, 0);
|
|
@@ -328,7 +298,13 @@ export class Consumer extends Base {
|
|
|
328
298
|
committedMetadata: null
|
|
329
299
|
});
|
|
330
300
|
}
|
|
331
|
-
|
|
301
|
+
this[kGetApi]('OffsetCommit', (error, api) => {
|
|
302
|
+
if (error) {
|
|
303
|
+
groupCallback(error, undefined);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
api(connection, this.groupId, this.generationId, this.memberId, null, Array.from(topics.values()), groupCallback);
|
|
307
|
+
});
|
|
332
308
|
}, error => {
|
|
333
309
|
callback(error);
|
|
334
310
|
});
|
|
@@ -369,7 +345,13 @@ export class Consumer extends Base {
|
|
|
369
345
|
retryCallback(error, undefined);
|
|
370
346
|
return;
|
|
371
347
|
}
|
|
372
|
-
|
|
348
|
+
this[kGetApi]('ListOffsets', (error, api) => {
|
|
349
|
+
if (error) {
|
|
350
|
+
retryCallback(error, undefined);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
api(connection, -1, FetchIsolationLevels[options.isolationLevel ?? this[kOptions].isolationLevel], Array.from(requests.values()), retryCallback);
|
|
354
|
+
});
|
|
373
355
|
});
|
|
374
356
|
}, concurrentCallback, 0);
|
|
375
357
|
}, (error, responses) => {
|
|
@@ -400,9 +382,15 @@ export class Consumer extends Base {
|
|
|
400
382
|
topics.push({ name, partitionIndexes: partitions });
|
|
401
383
|
}
|
|
402
384
|
this.#performGroupOperation('listCommits', (connection, groupCallback) => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
385
|
+
this[kGetApi]('OffsetFetch', (error, api) => {
|
|
386
|
+
if (error) {
|
|
387
|
+
groupCallback(error, undefined);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
api(connection,
|
|
391
|
+
// Note: once we start implementing KIP-848, the memberEpoch must be obtained
|
|
392
|
+
[{ groupId: this.groupId, memberId: this.memberId, memberEpoch: -1, topics }], false, groupCallback);
|
|
393
|
+
});
|
|
406
394
|
}, (error, response) => {
|
|
407
395
|
if (error) {
|
|
408
396
|
callback(error, undefined);
|
|
@@ -427,6 +415,97 @@ export class Consumer extends Base {
|
|
|
427
415
|
callback(null, this.#coordinatorId);
|
|
428
416
|
return;
|
|
429
417
|
}
|
|
418
|
+
consumerGroupChannel.traceCallback(this.#performFindGroupCoordinator, 0, createDiagnosticContext({ client: this, operation: 'findGroupCoordinator' }), this, callback);
|
|
419
|
+
}
|
|
420
|
+
#joinGroup(options, callback) {
|
|
421
|
+
consumerGroupChannel.traceCallback(this.#performJoinGroup, 1, createDiagnosticContext({ client: this, operation: 'joinGroup', options }), this, options, callback);
|
|
422
|
+
}
|
|
423
|
+
#leaveGroup(force, callback) {
|
|
424
|
+
consumerGroupChannel.traceCallback(this.#performLeaveGroup, 1, createDiagnosticContext({ client: this, operation: 'leaveGroup', force }), this, force, callback);
|
|
425
|
+
}
|
|
426
|
+
#syncGroup(callback) {
|
|
427
|
+
consumerGroupChannel.traceCallback(this.#performSyncGroup, 1, createDiagnosticContext({ client: this, operation: 'syncGroup' }), this, null, callback);
|
|
428
|
+
}
|
|
429
|
+
#heartbeat(options) {
|
|
430
|
+
const eventPayload = { groupId: this.groupId, memberId: this.memberId, generationId: this.generationId };
|
|
431
|
+
consumerHeartbeatChannel.traceCallback((this.#performDeduplicateGroupOperaton), 2, createDiagnosticContext({ client: this, operation: 'heartbeat' }), this, 'heartbeat', (connection, groupCallback) => {
|
|
432
|
+
// We have left the group in the meanwhile, abort
|
|
433
|
+
if (!this.#membershipActive) {
|
|
434
|
+
this.emitWithDebug('consumer:heartbeat', 'cancel', eventPayload);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
this.emitWithDebug('consumer:heartbeat', 'start', eventPayload);
|
|
438
|
+
this[kGetApi]('Heartbeat', (error, api) => {
|
|
439
|
+
if (error) {
|
|
440
|
+
groupCallback(error, undefined);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
api(connection, this.groupId, this.generationId, this.memberId, null, groupCallback);
|
|
444
|
+
});
|
|
445
|
+
}, error => {
|
|
446
|
+
// The heartbeat has been aborted elsewhere, ignore the response
|
|
447
|
+
if (this.#heartbeatInterval === null || !this.#membershipActive) {
|
|
448
|
+
this.emitWithDebug('consumer:heartbeat', 'cancel', eventPayload);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (error) {
|
|
452
|
+
this.#cancelHeartbeat();
|
|
453
|
+
if (this.#getRejoinError(error)) {
|
|
454
|
+
this[kPerformWithRetry]('rejoinGroup', retryCallback => {
|
|
455
|
+
this.#joinGroup(options, retryCallback);
|
|
456
|
+
}, error => {
|
|
457
|
+
if (error) {
|
|
458
|
+
this.emitWithDebug(null, 'error', error);
|
|
459
|
+
}
|
|
460
|
+
this.emitWithDebug('consumer', 'rejoin');
|
|
461
|
+
}, 0);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
this.emitWithDebug('consumer:heartbeat', 'error', { ...eventPayload, error });
|
|
465
|
+
// Note that here we purposely do not return, since it was not a group related problem we schedule another heartbeat
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
this.emitWithDebug('consumer:heartbeat', 'end', eventPayload);
|
|
469
|
+
}
|
|
470
|
+
this.#heartbeatInterval?.refresh();
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
#cancelHeartbeat() {
|
|
474
|
+
clearTimeout(this.#heartbeatInterval);
|
|
475
|
+
this.#heartbeatInterval = null;
|
|
476
|
+
}
|
|
477
|
+
#performConsume(options, trackTopics, callback) {
|
|
478
|
+
// Subscribe all topics
|
|
479
|
+
let joinNeeded = this.memberId === null;
|
|
480
|
+
if (trackTopics) {
|
|
481
|
+
for (const topic of options.topics) {
|
|
482
|
+
if (this.topics.track(topic)) {
|
|
483
|
+
joinNeeded = true;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
// If we need to (re)join the group, do that first and then try again
|
|
488
|
+
if (joinNeeded) {
|
|
489
|
+
this.joinGroup(options, error => {
|
|
490
|
+
if (error) {
|
|
491
|
+
callback(error, undefined);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.#performConsume(options, false, callback);
|
|
495
|
+
});
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
// Create the stream and start consuming
|
|
499
|
+
const stream = new MessagesStream(this, options);
|
|
500
|
+
this.#streams.add(stream);
|
|
501
|
+
this.#metricActiveStreams?.inc();
|
|
502
|
+
stream.once('close', () => {
|
|
503
|
+
this.#metricActiveStreams?.dec();
|
|
504
|
+
this.#streams.delete(stream);
|
|
505
|
+
});
|
|
506
|
+
callback(null, stream);
|
|
507
|
+
}
|
|
508
|
+
#performFindGroupCoordinator(callback) {
|
|
430
509
|
this[kPerformDeduplicated]('findGroupCoordinator', deduplicateCallback => {
|
|
431
510
|
this[kPerformWithRetry]('findGroupCoordinator', retryCallback => {
|
|
432
511
|
this[kConnections].getFirstAvailable(this[kBootstrapBrokers], (error, connection) => {
|
|
@@ -434,7 +513,13 @@ export class Consumer extends Base {
|
|
|
434
513
|
retryCallback(error, undefined);
|
|
435
514
|
return;
|
|
436
515
|
}
|
|
437
|
-
|
|
516
|
+
this[kGetApi]('FindCoordinator', (error, api) => {
|
|
517
|
+
if (error) {
|
|
518
|
+
retryCallback(error, undefined);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
api(connection, FindCoordinatorKeyTypes.GROUP, [this.groupId], retryCallback);
|
|
522
|
+
});
|
|
438
523
|
});
|
|
439
524
|
}, (error, response) => {
|
|
440
525
|
if (error) {
|
|
@@ -447,7 +532,7 @@ export class Consumer extends Base {
|
|
|
447
532
|
}, 0);
|
|
448
533
|
}, callback);
|
|
449
534
|
}
|
|
450
|
-
#
|
|
535
|
+
#performJoinGroup(options, callback) {
|
|
451
536
|
if (!this.#membershipActive) {
|
|
452
537
|
callback(null, undefined);
|
|
453
538
|
return;
|
|
@@ -461,7 +546,13 @@ export class Consumer extends Base {
|
|
|
461
546
|
});
|
|
462
547
|
}
|
|
463
548
|
this.#performDeduplicateGroupOperaton('joinGroup', (connection, groupCallback) => {
|
|
464
|
-
|
|
549
|
+
this[kGetApi]('JoinGroup', (error, api) => {
|
|
550
|
+
if (error) {
|
|
551
|
+
groupCallback(error, undefined);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
api(connection, this.groupId, options.sessionTimeout, options.rebalanceTimeout, this.memberId ?? '', null, 'consumer', protocols, '', groupCallback);
|
|
555
|
+
});
|
|
465
556
|
}, (error, response) => {
|
|
466
557
|
if (!this.#membershipActive) {
|
|
467
558
|
callback(null, undefined);
|
|
@@ -469,7 +560,7 @@ export class Consumer extends Base {
|
|
|
469
560
|
}
|
|
470
561
|
if (error) {
|
|
471
562
|
if (this.#getRejoinError(error)) {
|
|
472
|
-
this.#
|
|
563
|
+
this.#performJoinGroup(options, callback);
|
|
473
564
|
return;
|
|
474
565
|
}
|
|
475
566
|
callback(error, undefined);
|
|
@@ -483,14 +574,14 @@ export class Consumer extends Base {
|
|
|
483
574
|
this.#members.set(member.memberId, this.#decodeProtocolSubscriptionMetadata(member.memberId, member.metadata));
|
|
484
575
|
}
|
|
485
576
|
// Send a syncGroup request
|
|
486
|
-
this.#syncGroup(
|
|
577
|
+
this.#syncGroup((error, response) => {
|
|
487
578
|
if (!this.#membershipActive) {
|
|
488
579
|
callback(null, undefined);
|
|
489
580
|
return;
|
|
490
581
|
}
|
|
491
582
|
if (error) {
|
|
492
583
|
if (this.#getRejoinError(error)) {
|
|
493
|
-
this.#
|
|
584
|
+
this.#performJoinGroup(options, callback);
|
|
494
585
|
return;
|
|
495
586
|
}
|
|
496
587
|
callback(error, undefined);
|
|
@@ -512,7 +603,7 @@ export class Consumer extends Base {
|
|
|
512
603
|
});
|
|
513
604
|
});
|
|
514
605
|
}
|
|
515
|
-
#
|
|
606
|
+
#performLeaveGroup(force, callback) {
|
|
516
607
|
if (!this.memberId) {
|
|
517
608
|
callback(null);
|
|
518
609
|
return;
|
|
@@ -536,13 +627,19 @@ export class Consumer extends Base {
|
|
|
536
627
|
return;
|
|
537
628
|
}
|
|
538
629
|
// All streams are closed, try the operation again without force
|
|
539
|
-
this.#
|
|
630
|
+
this.#performLeaveGroup(false, callback);
|
|
540
631
|
});
|
|
541
632
|
return;
|
|
542
633
|
}
|
|
543
634
|
this.#cancelHeartbeat();
|
|
544
635
|
this.#performDeduplicateGroupOperaton('leaveGroup', (connection, groupCallback) => {
|
|
545
|
-
|
|
636
|
+
this[kGetApi]('LeaveGroup', (error, api) => {
|
|
637
|
+
if (error) {
|
|
638
|
+
groupCallback(error, undefined);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
api(connection, this.groupId, [{ memberId: this.memberId }], groupCallback);
|
|
642
|
+
});
|
|
546
643
|
}, error => {
|
|
547
644
|
if (error) {
|
|
548
645
|
const unknownMemberError = error.findBy?.('unknownMemberId', true);
|
|
@@ -563,7 +660,7 @@ export class Consumer extends Base {
|
|
|
563
660
|
callback(null);
|
|
564
661
|
});
|
|
565
662
|
}
|
|
566
|
-
#
|
|
663
|
+
#performSyncGroup(assignments, callback) {
|
|
567
664
|
if (!this.#membershipActive) {
|
|
568
665
|
callback(null, []);
|
|
569
666
|
return;
|
|
@@ -587,7 +684,7 @@ export class Consumer extends Base {
|
|
|
587
684
|
callback(error, undefined);
|
|
588
685
|
return;
|
|
589
686
|
}
|
|
590
|
-
this.#
|
|
687
|
+
this.#performSyncGroup(this.#roundRobinAssignments(metadata), callback);
|
|
591
688
|
});
|
|
592
689
|
return;
|
|
593
690
|
}
|
|
@@ -597,7 +694,13 @@ export class Consumer extends Base {
|
|
|
597
694
|
}
|
|
598
695
|
}
|
|
599
696
|
this.#performDeduplicateGroupOperaton('syncGroup', (connection, groupCallback) => {
|
|
600
|
-
|
|
697
|
+
this[kGetApi]('SyncGroup', (error, api) => {
|
|
698
|
+
if (error) {
|
|
699
|
+
groupCallback(error, undefined);
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
api(connection, this.groupId, this.generationId, this.memberId, null, 'consumer', this.#protocol, assignments, groupCallback);
|
|
703
|
+
});
|
|
601
704
|
}, (error, response) => {
|
|
602
705
|
if (!this.#membershipActive) {
|
|
603
706
|
callback(null, undefined);
|
|
@@ -618,48 +721,6 @@ export class Consumer extends Base {
|
|
|
618
721
|
callback(error, assignments);
|
|
619
722
|
});
|
|
620
723
|
}
|
|
621
|
-
#heartbeat(options) {
|
|
622
|
-
const eventPayload = { groupId: this.groupId, memberId: this.memberId, generationId: this.generationId };
|
|
623
|
-
this.#performDeduplicateGroupOperaton('heartbeat', (connection, groupCallback) => {
|
|
624
|
-
// We have left the group in the meanwhile, abort
|
|
625
|
-
if (!this.#membershipActive) {
|
|
626
|
-
this.emitWithDebug('consumer:heartbeat', 'cancel', eventPayload);
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
this.emitWithDebug('consumer:heartbeat', 'start', eventPayload);
|
|
630
|
-
heartbeatV4(connection, this.groupId, this.generationId, this.memberId, null, groupCallback);
|
|
631
|
-
}, error => {
|
|
632
|
-
// The heartbeat has been aborted elsewhere, ignore the response
|
|
633
|
-
if (this.#heartbeatInterval === null || !this.#membershipActive) {
|
|
634
|
-
this.emitWithDebug('consumer:heartbeat', 'cancel', eventPayload);
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
if (error) {
|
|
638
|
-
this.#cancelHeartbeat();
|
|
639
|
-
if (this.#getRejoinError(error)) {
|
|
640
|
-
this[kPerformWithRetry]('rejoinGroup', retryCallback => {
|
|
641
|
-
this.#joinGroup(options, retryCallback);
|
|
642
|
-
}, error => {
|
|
643
|
-
if (error) {
|
|
644
|
-
this.emitWithDebug(null, 'error', error);
|
|
645
|
-
}
|
|
646
|
-
this.emitWithDebug('consumer', 'rejoin');
|
|
647
|
-
}, 0);
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
this.emitWithDebug('consumer:heartbeat', 'error', { ...eventPayload, error });
|
|
651
|
-
// Note that here we purposely do not return, since it was not a group related problem we schedule another heartbeat
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
this.emitWithDebug('consumer:heartbeat', 'end', eventPayload);
|
|
655
|
-
}
|
|
656
|
-
this.#heartbeatInterval?.refresh();
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
#cancelHeartbeat() {
|
|
660
|
-
clearTimeout(this.#heartbeatInterval);
|
|
661
|
-
this.#heartbeatInterval = null;
|
|
662
|
-
}
|
|
663
724
|
#performDeduplicateGroupOperaton(operationId, operation, callback) {
|
|
664
725
|
return this[kPerformDeduplicated](operationId, deduplicateCallback => {
|
|
665
726
|
this.#performGroupOperation(operationId, operation, deduplicateCallback);
|
|
@@ -5,6 +5,7 @@ import { type CallbackWithPromise } from '../callbacks.ts';
|
|
|
5
5
|
import { type Consumer } from './consumer.ts';
|
|
6
6
|
import { type CommitOptionsPartition, type ConsumeOptions } from './types.ts';
|
|
7
7
|
export declare function noopDeserializer(data?: Buffer): Buffer | undefined;
|
|
8
|
+
export declare function defaultCorruptedMessageHandler(): boolean;
|
|
8
9
|
export declare class MessagesStream<Key, Value, HeaderKey, HeaderValue> extends Readable {
|
|
9
10
|
#private;
|
|
10
11
|
constructor(consumer: Consumer<Key, Value, HeaderKey, HeaderValue>, options: ConsumeOptions<Key, Value, HeaderKey, HeaderValue>);
|