Skip to content
Max DeLiso edited this page Aug 20, 2015 · 2 revisions

Migrating to 2.x

The major difference in API between 1.x and 2.x is removal of the #interval argument. If you were doing something like this in 1.x:

Retriable.retriable on: Timeout::Error, tries: 3, interval: 1 do
  # code here...
end

now becomes:

# Array.new(3, 1) # => [1, 1, 1]
Retriable.retriable on: Timeout::Error, intervals: Array.new(3, 1) do
  # code here...
end

Exponential Backoff

In 1.x, exponential backoff was accomplished via a Proc:

# with exponential back-off - sleep 2, 4, 8, 16, give up
Retriable.retriable tries: 4, interval: lambda {|attempts| 2 ** attempts} do
  # code here...
end

In 2.x, the equivalent would be:

Retriable.retriable tries: 4, base_interval: 1.0, multiplier: 2.0, rand_factor: 0.0 do
  # code here...
end

I would strongly recommend reading the README for more details on randomized exponential backoff.

Clone this wiki locally