From c9d073794fad1d88a3c99709ff744c7d8c570865 Mon Sep 17 00:00:00 2001 From: Ramakrishna Pattnaik Date: Tue, 17 May 2022 14:52:42 +0530 Subject: [PATCH] feat(consumer-group): display state (#1568) --- pkg/cmd/kafka/consumergroup/describe/describe.go | 3 ++- pkg/cmd/kafka/consumergroup/list/list.go | 8 +++++--- pkg/core/localize/locales/en/cmd/kafka.en.toml | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/kafka/consumergroup/describe/describe.go b/pkg/cmd/kafka/consumergroup/describe/describe.go index 2728a455f..5a4bb6919 100644 --- a/pkg/cmd/kafka/consumergroup/describe/describe.go +++ b/pkg/cmd/kafka/consumergroup/describe/describe.go @@ -189,7 +189,8 @@ func printConsumerGroupDetails(w io.Writer, consumerGroupData kafkainstanceclien partitionsWithLagCount := metrics.GetLaggingPartitions() unassignedPartitions := metrics.GetUnassignedPartitions() - fmt.Fprintln(w, color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.activeMembers")), activeMembersCount, "\t", color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.partitionsWithLag")), partitionsWithLagCount, "\t", color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.unassignedPartitions")), unassignedPartitions) + fmt.Fprintln(w, color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.activeMembers")), activeMembersCount, "\t", color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.partitionsWithLag")), partitionsWithLagCount, "\t") + fmt.Fprintln(w, color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.unassignedPartitions")), unassignedPartitions, color.Bold(localizer.MustLocalize("kafka.consumerGroup.describe.output.state")), consumerGroupData.GetState()) fmt.Fprintln(w, "") rows := mapConsumerGroupDescribeToTableFormat(consumers) diff --git a/pkg/cmd/kafka/consumergroup/list/list.go b/pkg/cmd/kafka/consumergroup/list/list.go index 554cd5ee2..ef680a907 100644 --- a/pkg/cmd/kafka/consumergroup/list/list.go +++ b/pkg/cmd/kafka/consumergroup/list/list.go @@ -41,9 +41,10 @@ type options struct { } type consumerGroupRow struct { - ConsumerGroupID string `json:"groupId,omitempty" header:"Consumer group ID"` - ActiveMembers int32 `json:"active_members,omitempty" header:"Active members"` - PartitionsWithLag int32 `json:"lag,omitempty" header:"Partitions with lag"` + ConsumerGroupID string `json:"groupId,omitempty" header:"Consumer group ID"` + ActiveMembers int32 `json:"active_members,omitempty" header:"Active members"` + PartitionsWithLag int32 `json:"lag,omitempty" header:"Partitions with lag"` + State kafkainstanceclient.ConsumerGroupState `json:"state,omitempty" header:"State"` } // NewListConsumerGroupCommand creates a new command to list consumer groups @@ -185,6 +186,7 @@ func mapConsumerGroupResultsToTableFormat(consumerGroups []kafkainstanceclient.C ConsumerGroupID: t.GetGroupId(), ActiveMembers: metrics.GetActiveConsumers(), PartitionsWithLag: metrics.GetLaggingPartitions(), + State: t.GetState(), } rows[i] = row } diff --git a/pkg/core/localize/locales/en/cmd/kafka.en.toml b/pkg/core/localize/locales/en/cmd/kafka.en.toml index 6a37f1e21..d30d4c5bc 100644 --- a/pkg/core/localize/locales/en/cmd/kafka.en.toml +++ b/pkg/core/localize/locales/en/cmd/kafka.en.toml @@ -190,6 +190,9 @@ one = 'ACTIVE MEMBERS:' [kafka.consumerGroup.describe.output.partitionsWithLag] one = 'PARTITIONS WITH LAG:' +[kafka.consumerGroup.describe.output.state] +one = 'STATE:' + [kafka.consumerGroup.describe.output.unassignedPartitions] one = 'UNASSIGNED PARTITIONS:'