Skip to content

adsteel/retry_on_error

 
 

Repository files navigation

Gem Version Build Status

RetryOnError

A simple utility for configuring retry behavior based on errors.

gem 'retry_on_error'

Usage

flaky_call = -> { Intercom::Client.new(...).users.create(params) }

# basic usage
# +max_wait: the maximum number of seconds the retries are allowed to take
# +delay: wait time (slee) between retries
RetryOnError.call(
  Intercom::ServerError,
  max_wait: 1,
  delay: 1
) do
  flaky_call.call()
end

# only retry errors with matching messages
RetryOnError.call(
  [ Intercom::ServerError, /error message regex/ ],
  max_wait: 1
) do
  flaky_call.call()
end

# retry on a variety of matching errors
RetryOnError.call(
  Intercom::ServiceUnavailableError,
  [ Intercom::ServerError, /error message regex/ ],
  max_wait: 1
) do
  flaky_call.call()
end

Local development

$ bundle install
$ bundle exec rspec spec

Contributions

Contributions welcomed! Please link an issue in every pull request, and please include tests.

About

Easily customize retry logic for blocks of code. Designed to handle cross network calls

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Ruby 98.5%
  • Shell 1.5%