Skip to content

feat: expose cluster ID via getClusterId() and describeCluster()#451

Open
robcarlan-datadog wants to merge 1 commit intoconfluentinc:masterfrom
robcarlan-datadog:feat/expose-cluster-id
Open

feat: expose cluster ID via getClusterId() and describeCluster()#451
robcarlan-datadog wants to merge 1 commit intoconfluentinc:masterfrom
robcarlan-datadog:feat/expose-cluster-id

Conversation

@robcarlan-datadog
Copy link

@robcarlan-datadog robcarlan-datadog commented Feb 19, 2026

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:

  • Adds NodeGetClusterId NAN_METHOD to Connection (src/connection.cc) which calls RdKafka::Handle::clusterid(timeout_ms)
  • Registers getClusterId on Producer, KafkaConsumer, and AdminClient native prototypes
  • Adds Client.prototype.getClusterId(timeout) JS wrapper (lib/client.js)
  • Adds admin.describeCluster() to the KafkaJS-compatible admin API (lib/kafkajs/_admin.js), matching the KafkaJS interface

I 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

  • New test: test/promisified/admin/describe_cluster.spec.js
  • Existing native tests pass (78 passing)
  • Verified getClusterId() returns correct value on Producer, Consumer, and AdminClient
  • Verified describeCluster() returns { clusterId, controller, brokers } matching KafkaJS format

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>
@robcarlan-datadog robcarlan-datadog marked this pull request as ready for review February 20, 2026 17:23
@robcarlan-datadog robcarlan-datadog requested review from a team as code owners February 20, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant