Method DelayBeforeNextAttempt
- Namespace
- MailFathom.Application.Resilience
- Assembly
- MailFathom.Application.dll
DelayBeforeNextAttempt(TimeSpan, TimeSpan, TimeSpan, int)
Computes how long the work waits before its next attempt.
public static TimeSpan DelayBeforeNextAttempt(TimeSpan baseDelay, TimeSpan maxDelay, TimeSpan minimumDelay, int attemptCount)
Parameters
baseDelayTimeSpanThe delay the first retry is drawn around, from which the doubling grows.
maxDelayTimeSpanThe ceiling a grown delay never exceeds.
minimumDelayTimeSpanThe delay no draw falls below, which is Zero for work that has no wait of its own to respect.
attemptCountintHow many attempts the work has already been handed out for, counting from one.
Returns
- TimeSpan
A jittered delay of at least half the grown ceiling, never below
minimumDelay, and at mostmaxDelay.
Remarks
The floor is bounded by the base delay rather than by the ceiling, because a floor above the range the first attempt draws from is a caller stating two delays that contradict each other rather than one curve with a lower bound.
Exceptions
- ArgumentOutOfRangeException
Thrown when
baseDelayis not positive, whenmaxDelayis below it, whenminimumDelayis negative or abovebaseDelay, or whenattemptCountis not positive.