moonzero · control plane v0.15.0 · 49 packages · 4 targets · Apache-2.0 docs / data / fx GitHub

07 / DATA

fx

Call a body until it stops raising, with a predicate that stops the ladder early for a failure that will not change; the same over a backoff; and a deadline that tells a slow answer (None) from a wrong one (an error).

fn[A] retry( body : () -> A raise, attempts~ : Int32 = 3, fatal~ : (Error) -> Bool = _error => false) -> A raise

itemCall body until it stops raising, at most attempts times, and report the last failure when every attempt raised. fatal stops the ladder early for a failure that will not change — a malformed request is not worth three attempts — and by default nothing is fatal.

async fn[A] retry_with_backoff( body : async () -> A, backoff~ : @moonward.Backoff = @moonward.backoff, fatal~ : (Error) -> Bool = _error => false) -> A

itemretry with a backoff between attempts: backoff decides how long to wait, and the nth wait is its nth delay. An attempt that raised the last time waits before the next one, so the first call is never delayed.