Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
milindl committed Dec 15, 2022
1 parent cac6e4e commit b3dcdad
Show file tree
Hide file tree
Showing 11 changed files with 423 additions and 376 deletions.
2 changes: 1 addition & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ admin_alter_consumer_group_offsets/admin_alter_consumer_group_offsets
admin_create_acls/admin_create_acls
admin_create_topic/admin_create_topic
admin_delete_acls/admin_delete_acls
admin_delete_groups/admin_delete_groups
admin_delete_consumer_groups/admin_delete_consumer_groups
admin_delete_topics/admin_delete_topics
admin_describe_acls/admin_describe_acls
admin_describe_config/admin_describe_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ func main() {
os.Exit(1)
}

fmt.Printf("AlterConsumerGroupOffsets result: %v\n", res)
fmt.Printf("AlterConsumerGroupOffsets result: %+v\n", res)
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

res, err := ac.DeleteGroups(ctx, groups,
res, err := ac.DeleteConsumerGroups(ctx, groups,
kafka.SetAdminRequestTimeout(time.Duration(timeoutSec)*time.Second))
if err != nil {
fmt.Printf("Failed to delete groups: %s\n", err)
os.Exit(1)
}

fmt.Printf("DeleteGroups result: %v\n", res)
fmt.Printf("DeleteConsumerGroups result: %+v\n", res)
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {
"State: %s\n"+
"Coordinator: %+v\n"+
"Members: %+v\n\n",
g.GroupId, g.Error, g.IsSimpleConsumerGroup, g.PartitionAssignor,
g.GroupID, g.Error, g.IsSimpleConsumerGroup, g.PartitionAssignor,
g.State, g.Coordinator, g.Members)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ func main() {
os.Exit(1)
}

fmt.Printf("ListConsumerGroupOffset result: %v\n", res)
fmt.Printf("ListConsumerGroupOffset result: %+v\n", res)
}
18 changes: 14 additions & 4 deletions examples/admin_list_consumer_groups/admin_list_consumer_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,28 @@ func main() {
listGroupRes, err := a.ListConsumerGroups(
ctx, kafka.SetAdminConsumerGroupStates(states))

if err != nil || len(listGroupRes.Errors) > 0 {
fmt.Printf("Failed to list groups: %s %v\n", err, listGroupRes.Errors)
if err != nil {
fmt.Printf("Failed to list groups with client-level error %s\n", err)
os.Exit(1)
}

// Print results
groups := listGroupRes.ConsumerGroupListings
groups := listGroupRes.Valid
fmt.Printf("A total of %d consumer group(s) listed:\n", len(groups))
for _, group := range groups {
fmt.Printf("GroupId: %s\n", group.GroupId)
fmt.Printf("GroupId: %s\n", group.GroupID)
fmt.Printf("State: %s\n", group.State)
fmt.Printf("IsSimpleConsumerGroup: %v\n", group.IsSimpleConsumerGroup)
fmt.Println()
}

errs := listGroupRes.Errors
if len(errs) == 0 {
return
}

fmt.Printf("A total of %d error(s) while listing:\n", len(errs))
for _, err := range errs {
fmt.Println(err)
}
}
Loading

0 comments on commit b3dcdad

Please sign in to comment.