Skip to content

Commit

Permalink
feat: add logs for retry producing with backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarrkok committed Dec 28, 2024
1 parent dff773b commit 029fd37
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions batch_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kafka
import (
"errors"
"fmt"
"github.com/gofiber/fiber/v2/log"
"time"

"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -263,7 +262,7 @@ func (b *batchConsumer) retryBatchWithBackoff(retryableMessages []kcronsumer.Mes
if produceErr == nil {
return nil
}
log.Warnf("Error producing message (attempt %d/%d): %v", attempt, 5, produceErr)
b.logger.Warnf("Error producing message (attempt %d/%d): %v", attempt, 5, produceErr)
time.Sleep((50 * time.Millisecond) * time.Duration(1<<attempt))
}

Expand Down
3 changes: 1 addition & 2 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kafka

import (
"fmt"
"github.com/gofiber/fiber/v2/log"
"time"

"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -175,7 +174,7 @@ func (c *consumer) retryWithBackoff(retryableMsg kcronsumer.Message) error {
if produceErr == nil {
return nil
}
log.Warnf("Error producing message (attempt %d/%d): %v", attempt, 5, produceErr)
c.logger.Warnf("Error producing message (attempt %d/%d): %v", attempt, 5, produceErr)
time.Sleep((50 * time.Millisecond) * time.Duration(1<<attempt))
}

Expand Down

0 comments on commit 029fd37

Please sign in to comment.