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
backoff()
View Source
backoff() :: %Exbackoff{
current: pos_integer(),
dest: pid(),
max: max(),
start: pos_integer(),
type: :normal | :jitter,
value: any()
}
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
fail(b)
View Source
fail(backoff()) :: {pos_integer(), backoff()}
fail(backoff()) :: {pos_integer(), backoff()}
Increments the value and return the new state with the new_delay
fire(exbackoff) View Source
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(exbackoff)
View Source
get(backoff()) :: pos_integer()
get(backoff()) :: pos_integer()
Reads the current backoff value.
increment(n)
View Source
increment(pos_integer()) :: pos_integer()
increment(pos_integer()) :: pos_integer()
Just do the increments by hand!
increment(n, max)
View Source
increment(pos_integer(), pos_integer()) :: pos_integer()
increment(pos_integer(), pos_integer()) :: pos_integer()
Increments the value (but won't excess the max value).
init(start, max)
View Source
init(pos_integer(), max()) :: backoff()
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)
View Source
init(pos_integer(), max(), pid() | nil, any() | nil) :: backoff()
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)
View Source
rand_increment(pos_integer()) :: pos_integer()
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)
View Source
rand_increment(pos_integer(), pos_integer()) :: pos_integer()
rand_increment(pos_integer(), pos_integer()) :: pos_integer()
Do the random increments. It wont excess the max value
succeed(b)
View Source
succeed(backoff()) :: {pos_integer(), backoff()}
succeed(backoff()) :: {pos_integer(), backoff()}
resets the values
type(b, atom) View Source
Swaps between the states of the backoff.