Skip to content

Commit

Permalink
Make sure DelayType function gets consistent values of n
Browse files Browse the repository at this point in the history
Without this change DelayType function gets n either from
0,1,2,... or from 1,2,3,... depending on the value of Attempts
config value.

This change unifies the behaviour and makes n always take values from
0,1,2,...

Fixes avast#124

Signed-off-by: Piotr Jastrzebski <[email protected]>
  • Loading branch information
haaawk committed Jan 21, 2025
1 parent 01d7e00 commit 08128e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
lastErr = err

config.onRetry(n, err)
n++
select {
case <-config.timer.After(delay(config, n, err)):
case <-config.context.Done():
Expand All @@ -165,6 +164,7 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
}
return emptyT, config.context.Err()
}
n++
}
}

Expand Down

0 comments on commit 08128e4

Please sign in to comment.