Skip to content

Commit

Permalink
Support creating new consumer groups, and add "earliest" offset
Browse files Browse the repository at this point in the history
  • Loading branch information
TyBrown committed Jul 10, 2024
1 parent a971bdb commit 72df438
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/kaf/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"

"golang.org/x/exp/slices"

"strconv"

"time"
Expand Down Expand Up @@ -196,7 +198,7 @@ func createGroupCommitOffsetCmd() *cobra.Command {
i, err := strconv.ParseInt(offset, 10, 64)
if err != nil {
// Try oldest/newest/..
if offset == "oldest" {
if offset == "oldest" || offset == "earliest" {
i = sarama.OffsetOldest
} else if offset == "newest" || offset == "latest" {
i = sarama.OffsetNewest
Expand Down Expand Up @@ -244,7 +246,7 @@ func createGroupCommitOffsetCmd() *cobra.Command {
}
for _, detail := range groupDescs {
state := detail.State
if state != "Empty" {
if !slices.Contains([]string{"Empty", "Dead"}, state) {
errorExit("Consumer group %s has active consumers in it, cannot set offset\n", group)
}
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require (
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand Down

0 comments on commit 72df438

Please sign in to comment.