Skip to content

Commit 8d7cef7

Browse files
committed
Make sure DelayType function gets consistent values of n
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 1,2,3,... Fixes #124 Signed-off-by: Piotr Jastrzebski <[email protected]>
1 parent 79a35c4 commit 8d7cef7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

retry.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
202202
if n == config.attempts-1 {
203203
break
204204
}
205-
205+
n++
206206
select {
207207
case <-config.timer.After(delay(config, n, err)):
208208
case <-config.context.Done():
@@ -213,7 +213,6 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
213213
return emptyT, append(errorLog, config.context.Err())
214214
}
215215

216-
n++
217216
shouldRetry = shouldRetry && n < config.attempts
218217
}
219218

0 commit comments

Comments
 (0)