Skip to content

Commit

Permalink
Merge pull request #14 from czeslavo/master
Browse files Browse the repository at this point in the history
Make exponential backoff in subscriber not expiring
  • Loading branch information
m110 authored Jun 7, 2021
2 parents 2d39aa7 + f033cee commit 7463808
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/googlecloud/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *messa
receiveFinished := make(chan struct{})
s.allSubscriptionsWaitGroup.Add(1)
go func() {
exponentialBackoff := backoff.NewExponentialBackOff()
exponentialBackoff.MaxElapsedTime = 0 // 0 means it never expires

if err := backoff.Retry(func() error {
err := s.receive(ctx, sub, logFields, output)
if err == nil {
Expand All @@ -188,7 +191,7 @@ func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *messa

s.logger.Error("Receiving messages failed, retrying", err, logFields)
return err
}, backoff.NewExponentialBackOff()); err != nil {
}, exponentialBackoff); err != nil {
s.logger.Error("Retrying receiving messages failed", err, logFields)
}

Expand Down

0 comments on commit 7463808

Please sign in to comment.