View Source Again.Backoff (again v0.1.1)

Describes backoff algorithms for how long to wait between retry attempts.

Time unit is milliseconds unless otherwose noted.

Summary

Functions

Use the same backoff duration after every retry. e.g. 100, 100, 100, 100, ...

Use an exponential backoff for each retry, starting with start_with. e.g. 100, 200, 400, 800, ...

Given an existing backoff policy, add jitter by introducing a randomness factor of percentage to its output.

Types

@type policy() :: (last_backoff :: pos_integer() -> next_backoff :: pos_integer())

Functions

Link to this function

constant_backoff(backoff)

View Source
@spec constant_backoff(backoff :: pos_integer()) :: policy()

Use the same backoff duration after every retry. e.g. 100, 100, 100, 100, ...

Link to this function

exponential_backoff(start_with)

View Source
@spec exponential_backoff(start_with :: pos_integer()) :: policy()

Use an exponential backoff for each retry, starting with start_with. e.g. 100, 200, 400, 800, ...

Link to this function

jitter(policy, percentage)

View Source
@spec jitter(policy :: policy(), percentage :: float()) :: policy()

Given an existing backoff policy, add jitter by introducing a randomness factor of percentage to its output.

For example, if the original policy produces 100 and we have percentage of 10, then we produce 90 < backoff < 110