Sha256: 4a7cfa08d2de98cdeb409e2926141b7514b55d10993449fdd7d1db035dcae2c9

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

# Exponential Retry

[![Gem Version](https://img.shields.io/gem/v/exp_retry.svg)](https://rubygems.org/gems/exp_retry)
[![Build Status](https://travis-ci.org/jfiander/exp-retry.svg)](https://travis-ci.org/jfiander/exp-retry)
[![Maintainability](https://api.codeclimate.com/v1/badges/4c8be06f11872994f2c7/maintainability)](https://codeclimate.com/github/jfiander/exp-retry/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/4c8be06f11872994f2c7/test_coverage)](https://codeclimate.com/github/jfiander/exp-retry/test_coverage)

A simple exponential backoff retry wrapper.

## Installation

Add this to your Gemfile:

```ruby
gem 'exp_retry'
```

Or manually install the gem:

```sh
gem install exp_retry
```

## Usage

You can wrap a simple block to enable retries:

```ruby
ExpRetry.new.call do
  something_unreliable
end
```

You can specify which exception class(es) to allow retries for:

```ruby
ExpRetry.new(exception: SpecificError).call do
  something_generic # errors will surface immediately
  something_specific # errors will trigger retries
end

ExpRetry.new(exception: [SpecificError, AnotherError]).call do
  something_generic # errors will surface immediately
  something_specific # errors will trigger retries
end
```

You can specify how many retries to allow:

```ruby
ExpRetry.new(retries: 5).call do
  something_unreliable # will retry 5 times
end
```

There is also a helper method to simplify calling on a new instance:

```ruby
ExpRetry.for(retries: 5, exception: [SpecificError, AnotherError]) do
  something_generic # errors will surface immediately
  something_specific # errors will trigger up to 5 retries
end
```

To display internal logging, run with the `verbose` flag:

```ruby
ExpRetry.for(retries: 5, exception: SpecificError, verbose: true) do
  something_generic # errors will surface immediately
  something_specific # errors will trigger up to 5 retries
end
```

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
exp_retry-0.0.14 Readme.md
exp_retry-0.0.13 Readme.md
exp_retry-0.0.12 Readme.md
exp_retry-0.0.11 Readme.md
exp_retry-0.0.10 Readme.md