Method DelayBeforeNextRun
- Namespace
- MailFathom.Application.Synchronization
- Assembly
- MailFathom.Application.dll
DelayBeforeNextRun(TimeSpan, TimeSpan, int)
Computes the delay before one account's next synchronization run.
public static TimeSpan DelayBeforeNextRun(TimeSpan interval, TimeSpan maxDelay, int consecutiveFailureCount)
Parameters
intervalTimeSpanThe configured interval a healthy account runs on.
maxDelayTimeSpanThe ceiling a backed-off delay never exceeds.
consecutiveFailureCountintHow many runs of this account failed in a row; zero after one succeeded.
Returns
- TimeSpan
The configured interval when nothing failed, otherwise a jittered delay of at least that interval and at most
maxDelay.
Remarks
A backed-off delay is never shorter than the configured interval. Backoff exists to approach a struggling server less often, so a ceiling or a jitter draw that let a failing account run sooner than a healthy one would invert the whole point of it.
Exceptions
- ArgumentOutOfRangeException
Thrown when the interval is not positive, the ceiling is below the interval, or the failure count is negative.