exbackoff v0.0.3 ExBackoff

ExBackoff is an Elixir library to deal with exponential backoffs and timers to be used within OTP processes when dealing with cyclical events, such as reconnections, or generally retrying things.

Summary

Types

struct contain state of the backoff module including the start, current and max value. Type of the backoff :normal or :jitter. Value to send and the destination when need to fire off message whe :timeout

Functions

Increments the value and return the new state with the new_delay

Starts a timer from the `backoff()’ argument, using erlang:start_timer/3. No reference tracking is done, and this is left to the user. This function is purely a convenience function

Reads the current backoff value

Just do the increments by hand!

Increments the value (but won’t excess the max value)

init function when the user doesn’t feel like using a timer provided by this library

init function when the user feels like using a timer provided by this library

Just do the random increments by hand! Choose delay uniformly from [0.5 * Time, 1.5 * Time] as recommended in: Sally Floyd and Van Jacobson, The Synchronization of Periodic Routing Messages, April 1994 IEEE/ACM Transactions on Networking. http://ee.lbl.gov/papers/sync_94.pdf

Do the random increments. It wont excess the max value

resets the values

Swaps between the states of the backoff

Types

backoff :: %ExBackoff{current: pos_integer, dest: pid, max: max, start: pos_integer, type: :normal | :jitter, value: any}

struct contain state of the backoff module including the start, current and max value. Type of the backoff :normal or :jitter. Value to send and the destination when need to fire off message whe :timeout

Functions

fail(ex_backoff)

Specs

fail(backoff) :: {pos_integer, backoff}

Increments the value and return the new state with the new_delay

fire(ex_backoff)

Specs

fire(backoff) :: reference

Starts a timer from the `backoff()’ argument, using erlang:start_timer/3. No reference tracking is done, and this is left to the user. This function is purely a convenience function.

get(ex_backoff)

Specs

get(backoff) :: pos_integer

Reads the current backoff value.

increment(n)

Specs

increment(pos_integer) :: pos_integer

Just do the increments by hand!

increment(n, max)

Specs

increment(pos_integer, pos_integer) :: pos_integer

Increments the value (but won’t excess the max value).

init(start, max)

Specs

init(pos_integer, max) :: backoff

init function when the user doesn’t feel like using a timer provided by this library

init(start, max, dest, value)

Specs

init(pos_integer, max, pid | nil, any | nil) :: backoff

init function when the user feels like using a timer provided by this library

rand_increment(n)

Specs

rand_increment(pos_integer) :: pos_integer

Just do the random increments by hand! Choose delay uniformly from [0.5 * Time, 1.5 * Time] as recommended in: Sally Floyd and Van Jacobson, The Synchronization of Periodic Routing Messages, April 1994 IEEE/ACM Transactions on Networking. http://ee.lbl.gov/papers/sync_94.pdf

rand_increment(n, max)

Specs

rand_increment(pos_integer, pos_integer) :: pos_integer

Do the random increments. It wont excess the max value

succeed(ex_backoff)

Specs

succeed(backoff) :: {pos_integer, backoff}

resets the values

type(ex_backoff, atom)

Specs

type(backoff, :normal | :jitter) :: backoff

Swaps between the states of the backoff.