mbr/elm-again/1.0.1

Again.Policy

Choose a retry schedule and how many attempts to allow.

type alias Policy =
{ schedule : Schedule
, limit : AttemptLimit
}

A retry schedule and an attempt limit.

= Unlimited
| MaxAttempts Int

Unlimited keeps offering retries.

MaxAttempts counts the initial operation as an attempt, so MaxAttempts 3 allows two retries. A limit of one or less allows no retries.

unlimited : Schedule -> Policy

Uses a schedule with no attempt limit.

attemptsLeft : Policy -> Int -> Maybe Int

Remaining attempts after the supplied count, or Nothing for an unlimited policy. Exhausted limits return Just 0.

allowsRetry : Policy -> Int -> Bool

Whether another attempt is allowed. The count includes the initial operation and any retries already made.

retryDelay : Policy -> Int -> Maybe Float

Delay in milliseconds before another attempt, or Nothing when exhausted. Count attempts already made, starting at one for the initial operation.