Skip to content

Commit

Permalink
chore: limit max retry interval for transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir20 committed Aug 16, 2024
1 parent e2fe003 commit 96e0d51
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion processor/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type handle struct {
maxRetry config.ValueLoader[int]
failOnUserTransformTimeout config.ValueLoader[bool]
failOnError config.ValueLoader[bool]
maxRetryBackoffInterval config.ValueLoader[time.Duration]

destTransformationURL string
userTransformationURL string
Expand Down Expand Up @@ -203,6 +204,8 @@ func NewTransformer(conf *config.Config, log logger.Logger, stat stats.Stats, op
trans.config.failOnUserTransformTimeout = conf.GetReloadableBoolVar(false, "Processor.Transformer.failOnUserTransformTimeout")
trans.config.failOnError = conf.GetReloadableBoolVar(false, "Processor.Transformer.failOnError")

trans.config.maxRetryBackoffInterval = conf.GetReloadableDurationVar(30, time.Second, "Processor.Transformer.maxRetryBackoffInterval")

trans.guardConcurrency = make(chan struct{}, trans.config.maxConcurrency)

if trans.client == nil {
Expand Down Expand Up @@ -439,6 +442,9 @@ func (trans *handle) doPost(ctx context.Context, rawJSON []byte, url, stage stri
resp *http.Response
respData []byte
)
retryStrategy := backoff.NewExponentialBackOff()
// MaxInterval caps the RetryInterval
retryStrategy.MaxInterval = trans.config.maxRetryBackoffInterval.Load()

err := backoff.RetryNotify(
func() error {
Expand Down Expand Up @@ -473,7 +479,7 @@ func (trans *handle) doPost(ctx context.Context, rawJSON []byte, url, stage stri
respData, reqErr = io.ReadAll(resp.Body)
return reqErr
},
backoff.WithMaxRetries(backoff.NewExponentialBackOff(), uint64(trans.config.maxRetry.Load())),
backoff.WithMaxRetries(retryStrategy, uint64(trans.config.maxRetry.Load())),
func(err error, t time.Duration) {
retryCount++
trans.logger.Warnn(
Expand Down

0 comments on commit 96e0d51

Please sign in to comment.