MCPcopy
hub / github.com/riverqueue/river / NextRetry

Method NextRetry

retry_policy.go:49–58  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

47// equivalent of the maximum of time.Duration to each retry, about 292 years.
48// The schedule is no longer exponential past this point.
49func (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
60func (p *DefaultClientRetryPolicy) timeNowUTC() time.Time {
61 if p.timeNowFunc != nil {

Callers

nothing calls this directly

Calls 4

timeNowUTCMethod · 0.95
retrySecondsMethod · 0.95
SecondsAsDurationFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected