Reliable
A ruby gem to reliably retry methods and blocks in a reusable, customizable, clean way.
Installation
Add this line to your application's Gemfile:
gem 'reliable'
And then execute:
$ bundle
Or install it yourself as:
$ gem install reliable
Usage
Reliable::Tryer.after_call = -> value:, error:, tries: {
puts "#{tries}: value=#{value}, error=#{error.class.name}(#{error})"
}
class Test
extend Reliable
class FooError < StandardError; end
def foo
raise FooError, 'message' if rand < 0.8
"successful result"
end
retries :foo, up_to: 3.times, on: FooError
end
Contributing