Skip to content

Commit d39f7e4

Browse files
committed
retry2: Grace period does not cause another attempt, it is just added to the specified duration.
1 parent 9c2dc0e commit d39f7e4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

internal/retry2/retry.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func BeginWithOptions(timeout time.Duration, opts ...Option) *RetryWithTimeout {
175175

176176
return &RetryWithTimeout{
177177
config: config,
178-
deadline: NewDeadline(timeout),
178+
deadline: NewDeadline(timeout + config.gracePeriod),
179179
}
180180
}
181181

@@ -189,13 +189,9 @@ func Begin(timeout time.Duration) *RetryWithTimeout {
189189
// The deadline is not checked on the first call to Continue.
190190
func (r *RetryWithTimeout) Continue(ctx context.Context) bool {
191191
if r.attempt != 0 && r.deadline.Remaining() == 0 {
192-
if r.config.gracePeriod == 0 {
193-
r.timedOut = true
194-
return false
195-
}
192+
r.timedOut = true
196193

197-
r.deadline = NewDeadline(r.config.gracePeriod)
198-
r.config.gracePeriod = 0
194+
return false
199195
}
200196

201197
r.sleep(ctx, r.config.delay(r.attempt))

0 commit comments

Comments
 (0)