NextRetry gets the next retry given for the given job, accounting for when it was last attempted and what attempt number that was. Reschedules using a basic exponential backoff of `ATTEMPT^4`, so after the first failure a new try will be scheduled in 1 seconds, 16 seconds after the second, 1 minute
(job *rivertype.JobRow)
| 47 | // equivalent of the maximum of time.Duration to each retry, about 292 years. |
| 48 | // The schedule is no longer exponential past this point. |
| 49 | func (p *DefaultClientRetryPolicy) NextRetry(job *rivertype.JobRow) time.Time { |
| 50 | // In modern versions of River `len(job.Errors)` is the same number as |
| 51 | // `attempt`. However, in older version snoozing a job wouldn't restore its |
| 52 | // attempt count to the pre-fetch value, and that would lead to incorrect |
| 53 | // retry durations when jobs are first snoozed, then retried. To avoid this |
| 54 | // and keep backward compatibility, the number of errors are used instead. |
| 55 | errorCount := len(job.Errors) + 1 |
| 56 | |
| 57 | return p.timeNowUTC().Add(timeutil.SecondsAsDuration(p.retrySeconds(errorCount))) |
| 58 | } |
| 59 | |
| 60 | func (p *DefaultClientRetryPolicy) timeNowUTC() time.Time { |
| 61 | if p.timeNowFunc != nil { |
nothing calls this directly
no test coverage detected