Skip to content

Commit

Permalink
Merge pull request #7 from slavabobik/add-no-commit-flag
Browse files Browse the repository at this point in the history
Added --no-commit flag for consuming command
  • Loading branch information
aermolaev authored Nov 25, 2022
2 parents 396f882 + 9362fd9 commit 1f7d321
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ services:
image: zookeeper:3.4.14
ports:
- "2181"
platform: "linux/x86_64"
jaeger:
image: jaegertracing/all-in-one:1.22
container_name: ${APP_PROJECT}_jaeger
Expand Down
5 changes: 5 additions & 0 deletions cmd/cmd_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func NewConsumeCmd() *cobra.Command {
groupFlag string
topicsFlag []string
countFlag int
noCommit bool
)

cmd := &cobra.Command{
Expand All @@ -37,6 +38,9 @@ func NewConsumeCmd() *cobra.Command {
return
}

if noCommit {
kafkaConfig.Consumer.Offsets.AutoCommit.Enable = false
}
// consumer
consumer, err := kafka.NewConsumerGroup(viper.GetStringSlice("broker"), groupFlag, kafkaConfig)
if err != nil {
Expand Down Expand Up @@ -77,6 +81,7 @@ func NewConsumeCmd() *cobra.Command {
flags.StringVarP(&groupFlag, "group", "G", "", "Consumer group")
flags.StringSliceVarP(&topicsFlag, "topic", "t", []string{}, "Topic to consume from")
flags.IntVarP(&countFlag, "count", "c", 0, "Exit after consuming this number of messages")
flags.BoolVar(&noCommit, "no-commit", false, "Consume messages without commiting offset")

_ = cmd.MarkFlagRequired("group")
_ = cmd.MarkFlagRequired("topic")
Expand Down

0 comments on commit 1f7d321

Please sign in to comment.