StaticisThe default judgement on whether a failure is transient.
The thrown value.
true when another attempt is reasonable.
An abort or a timeout is not retryable: the caller's own timeout already spent the budget it allowed.
An Error with a numeric status is read as an HTTP failure, and retried
only for 429 and the 5xx gateway family.
Anything else is treated as a network failure and retried, which is the safe
reading — fetch rejects for DNS, TLS and connection resets, and all three
are worth a second look.
StaticrunRuns an operation, retrying failures judged transient.
The operation's result.
The work to attempt. Must be safe to run more than once.
Overrides for the resolved delivery defaults.
Whatever the operation returned.
Backoff doubles: with the shipped defaults that is one attempt, 250 ms, a second, 500 ms, a third. The last failure is rethrown unchanged, so the caller sees the real cause rather than a wrapper.
ConfigurationError When delivery is not registered and
either attempts or backoffMs was left to default.
A bounded retry with exponential backoff.
Remarks
Bounded is the load-bearing word. A scheduled job runs against a wall-clock budget, and an unbounded retry turns one unreachable dependency into an invocation that never ends.
Why it is in the kernel
The kernel has declared the retry policy since 1.1.0:
delivery.retriesanddelivery.retryBackoffMsare in systemDefaults. Until this class, nothing in the package read them, so every consumer that wanted to honour them had to write the loop that does. This is that loop, beside the settings it reads.It reads them inside each call rather than at module scope. Resolving at module scope runs before the application's configure and throws ConfigurationError on startup.
What it does not know
Nothing here names a transport. The default judgement recognises an HTTP failure by shape — an
Errorcarrying a numericstatus— rather than by class, so this package takes no dependency on the client that threw it. A caller with its own non-retryable failures, such as a validation error, suppliesisRetryableand defers to Retry.isRetryable for the rest.Retry only what is safe to repeat. Replaying an operation that writes needs that write to be idempotent, which is a promise this class cannot make for the caller.
Example
Author
Bayu Dwiyan Satria
Version
1.3.1
Since
1.3.1