exbackoff v0.1.1 Exbackoff View Source

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.

Link to this section 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

Link to this section Types

Link to this type

backoff() View Source
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

Link to this section 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).

Link to this function

init(start, max) View Source
init(pos_integer(), max()) :: backoff()

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

Link to this function

init(start, max, dest, value) View Source
init(pos_integer(), max(), pid() | nil, any() | nil) :: backoff()

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

Link to this function

rand_increment(n) View Source
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

Link to this function

rand_increment(n, max) View Source
rand_increment(pos_integer(), pos_integer()) :: pos_integer()

Do the random increments. It wont excess the max value

resets the values

Link to this function

type(b, atom) View Source
type(backoff(), :normal | :jitter) :: backoff()

Swaps between the states of the backoff.