Skip to content

Commit 7cf20f4

Browse files
authored
Merge pull request #10 from theplant/refactor
Refactor RetryAfterFrom variable naming and comments
2 parents da4b90b + e01140e commit 7cf20f4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

ratelimiter.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ func (r *Reservation) RetryAfterFrom(t time.Time) (time.Duration, error) {
9696
return 0, errors.New("cannot get retry after from OK reservation")
9797
}
9898

99-
delay := r.TimeToAct.Sub(t) - r.MaxFutureReserve
100-
if delay < 0 {
99+
// We subtract MaxFutureReserve to calculate the minimum wait time before retrying
100+
// with the same ReserveRequest can succeed.
101+
retryAfter := r.TimeToAct.Sub(t) - r.MaxFutureReserve
102+
if retryAfter < 0 {
101103
return 0, nil
102104
}
103-
return delay, nil
105+
return retryAfter, nil
104106
}
105107

106108
// RetryAfter returns the duration to wait before retrying from now.

0 commit comments

Comments
 (0)