README.md in retries-0.0.1 vs README.md in retries-0.0.2
- old
+ new
@@ -1,13 +1,14 @@
# Retries
-Retries is a small gem that provides a single function, `with_retries`, to evaluate a block with randomized,
+Retries is a gem that provides a single function, `with_retries`, to evaluate a block with randomized,
truncated, exponential backoff.
-There are similar projects out there (see [here](https://github.com/afazio/retry_block) and
-[here](https://bitbucket.org/amanking/retry_this/wiki/Home)) but these will require you to implement the
-backoff scheme yourself. If you don't need randomized exponential backoff, you should check out those gems.
+There are similar projects out there (see [retry_block](https://github.com/afazio/retry_block) and
+[retry_this](https://bitbucket.org/amanking/retry_this/wiki/Home), for example) but these will require you to
+implement the backoff scheme yourself. If you don't need randomized exponential backoff, you should check out
+those gems.
## Installation
You can get the gem with `gem install retries` or simply add `gem "retries"` to your Gemfile if you're using
bundler.
@@ -17,11 +18,10 @@
Suppose we have some task we are trying to perform: `do_the_thing`. This might be a call to a third-party API
or a flaky service. Here's how you can try it three times before failing:
``` ruby
require "retries"
-
with_retries(:max_tries => 3) { do_the_thing }
```
The block is passed a single parameter, `attempt_number`, which is the number of attempts that have been made
(starting at 1):
@@ -80,19 +80,36 @@
``` ruby
with_retries(:max_tries => 10, :base_sleep_seconds => 0.1, :max_sleep_seconds => 2.0) { do_the_thing }
```
+### Testing
+
+In tests, you may wish to test that retries are being performed without any delay for sleeping:
+
+``` ruby
+Retries.sleep_enabled = false
+with_retries(:max_tries => 100) { raise "Boo!" } # Now this fails fast
+```
+
+Of course, this will mask any errors to the `:base_sleep_seconds` and `:max_sleep_seconds` parameters, so use
+with caution.
+
## Issues
File tickets here on Github.
## Development
To run the tests: first clone the repo, then
$ bundle install
$ bundle exec rake test
+
+## Authors
+
+* Harry Robertson
+* Caleb Spare
## License
Retries is released under the [MIT License](http://opensource.org/licenses/mit-license.php/).