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

Commit

Permalink
Merge pull request #42 from heetch/fix-panic
Browse files Browse the repository at this point in the history
Fix panicking
  • Loading branch information
Yasss authored Jun 13, 2019
2 parents 4aa9633 + 3327d2b commit 9e5bce5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *Consumer) setup() {
}
}

if c.retryStrategy == nil {
if c.config != nil && c.retryStrategy == nil {
// Note: the logic in handleMsg assumes that
// this does not terminate; be aware of that when changing
// this strategy.
Expand All @@ -101,14 +101,14 @@ func (c *Consumer) setup() {
// When Serve terminates it will return an Error or nil to indicate
// that it excited without error.
func (c *Consumer) Serve(config Config, addrs ...string) error {
c.setup()

c.config = &config
err := c.validateConfig()
if err != nil {
return err
}

c.setup()

topics := c.handlers.Topics()

consumerGroup := fmt.Sprintf("%s-consumer-group", c.config.ClientID)
Expand Down Expand Up @@ -239,7 +239,8 @@ func (c *Consumer) handleMsg(msg *sarama.ConsumerMessage) (*Message, int) {
}
return m, attempts
}
panic("unreachable")
return nil, attempts

}

// MetricsReporter is an interface that can be passed to set metrics hook to receive metrics
Expand Down

0 comments on commit 9e5bce5

Please sign in to comment.