Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 35892d8

Browse files
authored
Merge pull request #55 from heetch/rog-003-always-default-retry
consumer: use default retry interval when MaxRetryInterval is zero
2 parents 06e03f8 + ca6bcb5 commit 35892d8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

consumer/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type Config struct {
2222
KeyCodec codec.Codec
2323
}
2424

25+
const defaultRetryInterval = 5 * time.Second
26+
2527
// NewConfig creates a config with sane defaults.
2628
// The Sarama Cluster group mode will always be overwritten by the consumer
2729
// and thus cannot be changed, as the consumer is designed to use the ConsumerModePartitions mode.
@@ -40,7 +42,6 @@ func NewConfig(clientID string) Config {
4042
c.Group.Mode = cluster.ConsumerModePartitions
4143

4244
// Felice consumer configuration
43-
c.MaxRetryInterval = 5 * time.Second
4445
c.KeyCodec = codec.String() // defaults to String
4546
return c
4647
}

consumer/consumer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ func (c *Consumer) setup() {
8585
// Note: the logic in handleMsg assumes that
8686
// this does not terminate; be aware of that when changing
8787
// this strategy.
88+
if c.config.MaxRetryInterval <= 0 {
89+
c.config.MaxRetryInterval = defaultRetryInterval
90+
}
8891
c.retryStrategy = retry.Exponential{
8992
Initial: time.Millisecond,
9093
Factor: 2,

0 commit comments

Comments
 (0)