feat: expose cluster ID via getClusterId() and describeCluster()#451
Open
robcarlan-datadog wants to merge 1 commit intoconfluentinc:masterfrom
Open
feat: expose cluster ID via getClusterId() and describeCluster()#451robcarlan-datadog wants to merge 1 commit intoconfluentinc:masterfrom
robcarlan-datadog wants to merge 1 commit intoconfluentinc:masterfrom
Conversation
librdkafka provides rd_kafka_clusterid() to retrieve the cluster ID from broker metadata, but the Node.js binding never exposed it. This change: - Adds NodeGetClusterId NAN_METHOD to Connection (src/connection.cc) which calls RdKafka::Handle::clusterid() - Registers getClusterId on Producer, KafkaConsumer, and AdminClient native prototypes - Adds Client.prototype.getClusterId() JS wrapper (lib/client.js) - Adds admin.describeCluster() to the KafkaJS-compatible admin API (lib/kafkajs/_admin.js), matching the KafkaJS interface - Adds test for describeCluster Closes confluentinc#28 (partially - adds describeCluster admin operation) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39a0314 to
acea721
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
librdkafka provides
rd_kafka_clusterid()to retrieve the cluster ID from broker metadata, but the Node.js C++ binding never exposed it. This means there is no way to get the Kafka cluster ID from JavaScript, despite the underlying C library fully supporting it.This change:
NodeGetClusterIdNAN_METHOD toConnection(src/connection.cc) which callsRdKafka::Handle::clusterid(timeout_ms)getClusterIdonProducer,KafkaConsumer, andAdminClientnative prototypesClient.prototype.getClusterId(timeout)JS wrapper (lib/client.js)admin.describeCluster()to the KafkaJS-compatible admin API (lib/kafkajs/_admin.js), matching the KafkaJS interfaceI got Claude to help me with this, but it seems like a fairly straightforward change.
Motivation
Related: #28 (adds describeCluster admin operation)
Related: node-rdkafka #642 (same gap in the upstream project, closed as stale)
Test plan
test/promisified/admin/describe_cluster.spec.jsgetClusterId()returns correct value on Producer, Consumer, and AdminClientdescribeCluster()returns{ clusterId, controller, brokers }matching KafkaJS format