Skip to content

Commit 510a6c3

Browse files
committed
add coordinator to output
1 parent 501baac commit 510a6c3

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ State: Stable
138138
Type: 2
139139
There are 2 members:
140140
| index | client id | consumer id | host | assignments |
141-
| 0 | consumer-sub-1 | consumer-sub-1-b97d2b45-86cf-4352-8e82-9ebdfd6fbff6 | /127.0.0.1:54214 | [test-0, test-1]
142-
| 1 | consumer-sub-2 | consumer-sub-2-63b7c688-3007-4650-91eb-404284dfd837 | /127.0.0.1:54213 | [test-2, test-3]
141+
| 0 | consumer-sub-1 | consumer-sub-1-b97d2b45-86cf-4352-8e82-9ebdfd6fbff6 | /127.0.0.1:54214 | [test-0, test-1] |
142+
| 1 | consumer-sub-2 | consumer-sub-2-63b7c688-3007-4650-91eb-404284dfd837 | /127.0.0.1:54213 | [test-2, test-3] |
143143
```
144144
145145
The format of each line is `[index] <group-id> <state>`.

include/snctl-cpp/groups/describe_group.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#include <ostream>
2424
#include <string>
2525

26+
static std::ostream &operator<<(std::ostream &os, const rd_kafka_Node_t *node) {
27+
os << rd_kafka_Node_host(node) << ":" << rd_kafka_Node_port(node);
28+
if (const auto *rack = rd_kafka_Node_rack(node); rack != nullptr) {
29+
os << " (rack: " << rack << ")";
30+
}
31+
return os;
32+
}
33+
2634
static std::ostream &operator<<(std::ostream &os,
2735
const rd_kafka_topic_partition_t &partition) {
2836
os << partition.topic << "-" << partition.partition;
@@ -59,8 +67,6 @@ inline void describe_group(rd_kafka_t *rk, rd_kafka_queue_t *rkqu,
5967
return;
6068
}
6169

62-
const auto is_simple =
63-
rd_kafka_ConsumerGroupDescription_is_simple_consumer_group(group);
6470
const auto *assignor =
6571
rd_kafka_ConsumerGroupDescription_partition_assignor(group);
6672
const auto state = rd_kafka_ConsumerGroupDescription_state(group);
@@ -72,9 +78,10 @@ inline void describe_group(rd_kafka_t *rk, rd_kafka_queue_t *rkqu,
7278
std::cout << "Assignor: " << assignor << std::endl;
7379
std::cout << "State: " << state_name << std::endl;
7480
std::cout << "Type: " << type << std::endl;
81+
std::cout << "Coordinator: " << node << std::endl;
7582
const auto member_count =
7683
rd_kafka_ConsumerGroupDescription_member_count(group);
77-
;
84+
7885
if (member_count > 0) {
7986
std::cout << "There are " << member_count << " members:" << std::endl;
8087
std::cout << "| index | client id | consumer id | host | assignments |"
@@ -100,7 +107,7 @@ inline void describe_group(rd_kafka_t *rk, rd_kafka_queue_t *rkqu,
100107
}
101108
std::cout << partitions->elems[j];
102109
}
103-
std::cout << "]" << std::endl;
110+
std::cout << "] |" << std::endl;
104111
}
105112

106113
} catch (const std::runtime_error &e) {

0 commit comments

Comments
 (0)