$ gem install exponential_backoff
require 'exponential_backoff'
ExponentialBackoff.try(3) do
res = HTTP.get(url)
fail if res.error?
end
# or
begin
ExponentialBackoff.try(2) { HTTP.get('www.google.com') }
rescue => e
e.errors # => [#<RuntimeError: Blah>, #<ConnectionError: Bleh>]
end
ExponentialBackoff.try(max_number_of_tries) { request }