Skip to content

Commit

Permalink
feat(consumer-group): display state (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 authored May 17, 2022
1 parent 789102f commit c9d0737
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/cmd/kafka/consumergroup/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/kafka/consumergroup/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -185,6 +186,7 @@ func mapConsumerGroupResultsToTableFormat(consumerGroups []kafkainstanceclient.C
ConsumerGroupID: t.GetGroupId(),
ActiveMembers: metrics.GetActiveConsumers(),
PartitionsWithLag: metrics.GetLaggingPartitions(),
State: t.GetState(),
}
rows[i] = row
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/core/localize/locales/en/cmd/kafka.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:'

Expand Down

0 comments on commit c9d0737

Please sign in to comment.