Class JitteredRetryBackoff
- Namespace
- MailFathom.Application.Resilience
- Assembly
- MailFathom.Application.dll
Decides how long a unit of durable work waits before it is attempted again after a transient failure.
public static class JitteredRetryBackoff
- Inheritance
-
JitteredRetryBackoff
- Inherited Members
Remarks
This is a scheduler's own backoff, and it is a different decision from the one an adapter's resilience pipeline makes. The pipeline decides whether one call to a dependency is worth repeating within a single attempt and has already spent that budget by the time the work raises; this decides when the whole unit is worth attempting again, minutes later and in a process that need not be the one that failed. The two never wrap each other, which is what keeps the attempt counts from multiplying into a retry storm.
It is shared by the durable job queue and the outbox because both answer that question about work of their own, and a second implementation of it would be a second set of jitter arithmetic to get subtly wrong.
The delay doubles per attempt and is drawn from a range rather than computed exactly. Work that failed together failed on the same dependency, and an exact delay would return every one of them to it in the same instant on every later attempt. Half the ceiling is the floor of the draw, so a delay always at least halves the rate of approach while never exceeding the configured maximum.
Methods
- DelayBeforeNextAttempt(TimeSpan, TimeSpan, int)
Computes how long the work waits before its next attempt.