Skip to content

Commit

Permalink
kafka(consumer): Add ConsumeRegex (#336)
Browse files Browse the repository at this point in the history
Adds a new option to allow to consume from a regex expression.

Signed-off-by: Marc Lopez Rubio <[email protected]>
  • Loading branch information
marclop authored Dec 4, 2023
1 parent 2335124 commit 7465ae0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kafka/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type ConsumerConfig struct {
CommonConfig
// Topics that the consumer will consume messages from
Topics []apmqueue.Topic
// ConsumeRegex sets the client to parse all topics passed to ConsumeTopics
// as regular expressions.
ConsumeRegex bool
// GroupID to join as part of the consumer group.
GroupID string
// MaxPollRecords defines an upper bound to the number of records that can
Expand Down Expand Up @@ -184,6 +187,9 @@ func NewConsumer(cfg ConsumerConfig) (*Consumer, error) {
kgo.OnPartitionsLost(consumer.lost),
kgo.OnPartitionsRevoked(consumer.lost),
}
if cfg.ConsumeRegex {
opts = append(opts, kgo.ConsumeRegex())
}
if cfg.MaxPollWait > 0 {
opts = append(opts, kgo.FetchMaxWait(cfg.MaxPollWait))
}
Expand Down

0 comments on commit 7465ae0

Please sign in to comment.