mbr/elm-again/1.0.0

NOTE: the latest version is 1.0.1

Again.Schedule

Choose how long to wait between retries.

import Again.Schedule as Schedule exposing (Schedule(..))


schedule =
    ImmediatelyThen
        (ExponentialBackoff
            { initialDelay = 1000
            , multiplier = 2
            , maxDelay = 4000
            }
        )


delays =
    List.map (Schedule.delay schedule) [ 0, 1, 2, 3, 4 ]

This produces [ 0, 1000, 2000, 4000, 4000 ] milliseconds: retry immediately, then back off up to four seconds.

= Periodic { delay : Float }
| ExponentialBackoff
{ initialDelay : Float
, multiplier : Float
, maxDelay : Float
}
| ImmediatelyThen Schedule

Choose how long to wait before each retry. All delays are in milliseconds.

Periodic uses the same delay for every retry.

ExponentialBackoff starts with initialDelay, then multiplies the delay by multiplier for each subsequent retry, up to maxDelay.

ImmediatelyThen retries once without waiting, then follows the wrapped schedule from its first delay. Wrap it around either of the other variants, or nest it for several immediate retries.

Choose a multiplier of one or more and delays of zero or more, with maxDelay at least as large as initialDelay. The schedule uses your values as given, so make sure they're finite numbers.

Retry without waiting, every time. Equivalent to Periodic { delay = 0 }.

delay : Schedule -> Int -> Float

Returns a delay for a nonnegative, zero-based retry index.