Skip to content
This repository was archived by the owner on Mar 30, 2021. It is now read-only.

Commit 10a35bc

Browse files
committed
Clean-up README.md
1 parent dd22afd commit 10a35bc

File tree

1 file changed

+58
-62
lines changed

1 file changed

+58
-62
lines changed

README.md

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resque-retry
22
============
33

4-
A [Resque][rq] plugin. Requires Resque ~> 1.25 & [resque-scheduler][rqs] ~> 4.0.
4+
A [Resque][resque] plugin. Requires Resque ~> 1.25 & [resque-scheduler][resque-scheduler] ~> 4.0.
55

66
This gem provides retry, delay and exponential backoff support for resque jobs.
77

@@ -18,19 +18,20 @@ Install & Quick Start
1818
---------------------
1919

2020
To install:
21+
```
22+
$ gem install resque-retry
23+
```
2124

22-
$ gem install resque-retry
23-
24-
If you're using [Bundler][bundler] to manage your dependencies, you should add `gem
25-
'resque-retry'` to your projects `Gemfile`.
25+
If you're using [Bundler][bundler] to manage your dependencies, you should add
26+
`gem 'resque-retry'` to your `Gemfile`.
2627

2728
Add this to your `Rakefile`:
2829
```ruby
2930
require 'resque/tasks'
3031
require 'resque/scheduler/tasks'
3132
```
3233

33-
The delay between retry attempts is provided by [resque-scheduler][rqs].
34+
The delay between retry attempts is provided by [resque-scheduler][resque-scheduler].
3435
You'll want to run the scheduler process, otherwise delayed retry attempts
3536
will never perform:
3637
```
@@ -79,7 +80,8 @@ actually completed successfully just by just using the resque-web interface.
7980

8081
### Failure Backend
8182

82-
`MultipleWithRetrySuppression` is a multiple failure backend, with retry suppression.
83+
`MultipleWithRetrySuppression` is a multiple failure backend, with retry
84+
suppression.
8385

8486
Here's an example, using the Redis failure backend:
8587
```ruby
@@ -92,34 +94,33 @@ Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Failure::Redis]
9294
Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression
9395
```
9496

95-
If a job fails, but **can and will** retry, the failure details wont be
96-
logged in the Redis failed queue *(visible via resque-web)*.
97+
If a job fails, but **can and will** retry, the failure details wont be logged
98+
in the Redis failed queue *(visible via resque-web)*.
9799

98100
If the job fails, but **can't or won't** retry, the failure will be logged in
99101
the Redis failed queue, like a normal failure *(without retry)* would.
100102

101103
### Resque Web Additions
102104

103105
If you're using the `MultipleWithRetrySuppression` failure backend, you should
104-
also checkout the resque-web additions!
106+
also checkout the `resque-web` additions!
105107

106108
The new Retry tab displays delayed jobs with retry information; the number of
107109
attempts and the exception details from the last failure.
108110

109111

110112
### Configuring and running the Resque-Web Interface
111113

112-
#### Using a Rack configuration:
113-
114-
One alternative is to use a rack configuration file. To use this, make
115-
sure you include this in your `config.ru` or similar file:
114+
#### Using a Rack configuration:
116115

116+
One alternative is to use a rack configuration file. To use this, make sure you
117+
include this in your `config.ru` or similar file:
117118
```ruby
118119
require 'resque-retry'
119120
require 'resque-retry/server'
120121

121122
# Make sure to require your workers & application code below this line:
122-
# require '[path]/[to]/[jobs]/your_worker'
123+
# require '[path]/[to]/[jobs]/your_worker'
123124

124125
# Run the server
125126
run Resque::Server.new
@@ -132,33 +133,30 @@ rackup -p 9292 config.ru
132133

133134
When using bundler, you can also run the server like this:
134135
```
135-
bundle exec rackup -p 9292 config.ru
136+
bundle exec rackup -p 9292 config.ru
136137
```
137138

138139

139140
#### Using the 'resque-web' command with a configuration file:
140141

141-
Another alternative is to use resque's built-in 'resque-web' command with
142-
the additional resque-retry tabs. In order to do this, you must first create
143-
a configuration file. For the sake of this example we'll create the configuration
144-
file in a 'config' directory, and name it 'resque_web_config.rb'. In practice
145-
you could rename this configuration file to anything you'd like and place in your
146-
project in any directory of your choosing. The contents of the configuration file
142+
Another alternative is to use resque's built-in 'resque-web' command with the
143+
additional resque-retry tabs. In order to do this, you must first create a
144+
configuration file. For the sake of this example we'll create the configuration
145+
file in a 'config' directory, and name it 'resque_web_config.rb'. In practice
146+
you could rename this configuration file to anything you like and place in your
147+
project in a directory of your choosing. The contents of the configuration file
147148
would look like this:
148-
149149
```ruby
150150
# [app_dir]/config/resque_web_config.rb
151151
require 'resque-retry'
152152
require 'resque-retry/server'
153153

154154
# Make sure to require your workers & application code below this line:
155-
# require '[path]/[to]/[jobs]/your_worker'
156-
155+
# require '[path]/[to]/[jobs]/your_worker'
157156
```
158157

159158
Once you have the configuration file ready, you can pass the configuration file
160159
to the resque-web command as a parameter, like so:
161-
162160
```
163161
resque-web [app_dir]/config/resque_web_config.rb
164162
```
@@ -170,8 +168,8 @@ Retry Options & Logic
170168
Please take a look at the [yardoc](http://rubydoc.info/gems/resque-retry)/code
171169
for more details on methods you may wish to override.
172170

173-
Customisation is pretty easy, the below examples should give you
174-
some ideas =), adapt for your own usage and feel free to pick and mix!
171+
Customisation is pretty easy, the below examples should give you some ideas =),
172+
adapt for your own usage and feel free to pick and mix!
175173

176174
### Retry Defaults
177175

@@ -208,11 +206,10 @@ class DeliverWebHook
208206
end
209207
```
210208

211-
The above modification will allow your job to retry up to 10 times, with
212-
a delay of 120 seconds, or 2 minutes between retry attempts.
209+
The above modification will allow your job to retry up to 10 times, with a delay
210+
of 120 seconds, or 2 minutes between retry attempts.
213211

214-
Alternatively you could override the `retry_delay` method to do something
215-
more special.
212+
You can override the `retry_delay` method to set the delay value dynamically.
216213

217214
### Sleep After Requeuing
218215

@@ -235,14 +232,14 @@ end
235232
This retries the job once and causes the worker that failed to sleep for 5
236233
seconds after requeuing the job. If there are multiple workers in the system
237234
this allows the job to be retried immediately while the original worker heals
238-
itself.For example failed jobs may cause other (non-worker) OS processes to
239-
die. A system monitor such as [god][god] can fix the server while the job is
240-
being retried on a different worker.
235+
itself. For example failed jobs may cause other (non-worker) OS processes to
236+
die. A system monitor such as [monit][monit] or [god][god] can fix the server
237+
while the job is being retried on a different worker.
241238

242239
`@sleep_after_requeue` is independent of `@retry_delay`. If you set both, they
243240
both take effect.
244241

245-
You can override the method `sleep_after_requeue` to set the sleep value
242+
You can override the `sleep_after_requeue` method to set the sleep value
246243
dynamically.
247244

248245
### Exponential Backoff
@@ -263,17 +260,17 @@ end
263260
```
264261
key: m = minutes, h = hours
265262
266-
no delay, 1m, 10m, 1h, 3h, 6h
263+
0s, 1m, 10m, 1h, 3h, 6h
267264
@backoff_strategy = [0, 60, 600, 3600, 10800, 21600]
268265
@retry_delay_multiplicand_min = 1.0
269266
@retry_delay_multiplicand_max = 1.0
270267
```
271268

272-
The first delay will be 0 seconds, the 2nd will be 60 seconds, etc...
273-
Again, tweak to your own needs.
269+
The first delay will be 0 seconds, the 2nd will be 60 seconds, etc... Again,
270+
tweak to your own needs.
274271

275-
The number of retries is equal to the size of the `backoff_strategy`
276-
array, unless you set `retry_limit` yourself.
272+
The number of retries is equal to the size of the `backoff_strategy` array,
273+
unless you set `retry_limit` yourself.
277274

278275
The delay values will be multiplied by a random `Float` value between
279276
`retry_delay_multiplicand_min` and `retry_delay_multiplicand_max` (both have a
@@ -284,8 +281,8 @@ them all retried on the same schedule.
284281

285282
### Retry Specific Exceptions
286283

287-
The default will allow a retry for any type of exception. You may change
288-
it so only specific exceptions are retried using `retry_exceptions`:
284+
The default will allow a retry for any type of exception. You may change it so
285+
only specific exceptions are retried using `retry_exceptions`:
289286
```ruby
290287
class DeliverSMS
291288
extend Resque::Plugins::Retry
@@ -305,8 +302,8 @@ exception is thrown.
305302
You may also want to specify different retry delays for different exception
306303
types. You may optionally set `@retry_exceptions` to a hash where the keys are
307304
your specific exception classes to retry on, and the values are your retry
308-
delays in seconds or an array of retry delays to be used similar to
309-
exponential backoff.
305+
delays in seconds or an array of retry delays to be used similar to exponential
306+
backoff.
310307
```ruby
311308
class DeliverSMS
312309
extend Resque::Plugins::Retry
@@ -379,8 +376,8 @@ job should retry.
379376

380377
### Retry Arguments
381378

382-
You may override `retry_args`, which is passed the current
383-
job arguments, to modify the arguments for the next retry attempt.
379+
You may override `retry_args`, which is passed the current job arguments, to
380+
modify the arguments for the next retry attempt.
384381
```ruby
385382
class DeliverViaSMSC
386383
extend Resque::Plugins::Retry
@@ -397,10 +394,10 @@ class DeliverViaSMSC
397394
end
398395
```
399396

400-
Alternatively, if you require finer control of the args based on the
401-
exception thrown, you may override `retry_args_for_exception`, which is passed
402-
the exception and the current job arguments, to modify the arguments for the
403-
next retry attempt.
397+
Alternatively, if you require finer control of the args based on the exception
398+
thrown, you may override `retry_args_for_exception`, which is passed the
399+
exception and the current job arguments, to modify the arguments for the next
400+
retry attempt.
404401
```ruby
405402
class DeliverViaSMSC
406403
extend Resque::Plugins::Retry
@@ -418,15 +415,15 @@ end
418415
```
419416
### Job Retry Identifier/Key
420417

421-
The retry attempt is incremented and stored in a Redis key. The key is
422-
built using the `retry_identifier`. If you have a lot of arguments or really long
418+
The retry attempt is incremented and stored in a Redis key. The key is built
419+
using the `retry_identifier`. If you have a lot of arguments or really long
423420
ones, you should consider overriding `retry_identifier` to define a more precise
424421
or loose custom retry identifier.
425422

426-
The default retry identifier is just your job arguments joined with a dash `-`.
423+
The default identifier is just your job arguments joined with a dash `'-'`.
427424

428-
By default the key uses this format:
429-
`resque-retry:<job class name>:<retry_identifier>`.
425+
By default the key uses this format:
426+
`'resque-retry:<job class name>:<retry_identifier>'`.
430427

431428
Or you can define the entire key by overriding `redis_retry_key`.
432429
```ruby
@@ -448,7 +445,6 @@ end
448445

449446
Allow the Redis to expire stale retry counters from the database by setting
450447
`@expire_retry_key_after`:
451-
452448
```ruby
453449
class DeliverSMS
454450
extend Resque::Plugins::Retry
@@ -459,13 +455,12 @@ class DeliverSMS
459455
heavy_lifting
460456
end
461457
end
462-
463458
```
464459

465460
This saves you from having to run a "house cleaning" or "errand" job.
466461

467462
The expiary timeout is "pushed forward" or "touched" after each failure to
468-
ensure its not expired too soon.
463+
ensure it's not expired too soon.
469464

470465
### Debug Plugin Logging
471466

@@ -483,7 +478,8 @@ Contributing/Pull Requests
483478
* Send us a pull request. Bonus points for topic branches.
484479
* If you edit the gemspec/version etc, please do so in another commit.
485480

486-
[god]: http://github.com/mojombo/god
487-
[rq]: http://github.com/resque/resque
488-
[rqs]: http://github.com/resque/resque-scheduler
481+
[monit]: https://mmonit.com
482+
[god]: http://godrb.com
483+
[resque]: http://github.com/resque/resque
484+
[resque-scheduler]: http://github.com/resque/resque-scheduler
489485
[bundler]: http://bundler.io

0 commit comments

Comments
 (0)