resque-retry 1.6.0 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.md +76 -24
- data/README.md +20 -9
- data/lib/resque-retry/server.rb +13 -5
- data/lib/resque-retry/version.rb +1 -1
- data/lib/resque/failure/multiple_with_retry_suppression.rb +7 -5
- data/lib/resque/plugins/exponential_backoff.rb +2 -1
- data/lib/resque/plugins/retry.rb +26 -13
- data/resque-retry.gemspec +0 -1
- data/test/exponential_backoff_test.rb +7 -0
- data/test/retry_exception_delay_test.rb +9 -1
- data/test/retry_test.rb +7 -7
- data/test/test_jobs.rb +36 -9
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab175830aa9de0d24e514a8bd054b1ebe8a2924ba134fd975013685e84828b9d
|
4
|
+
data.tar.gz: a6cb49fb45375e4a82a8811e126f428de4acda1248d7b6cc6de5df6d9b6340bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4176df779bbc212e25d64190ae7680ee410beebb663d6b502f45fd73532b14fa4ed9f86dc76e74474dd757247b45b0a8503037a6154c814ffad159dec22413a
|
7
|
+
data.tar.gz: 2109a5558025ff2d7b5b8e1cd952242aad11641b11b1036332d2f68111c1d6ca5f9de402ec92376aedff37d6dff534bed0e017196e85f451b976e405168a71da
|
data/HISTORY.md
CHANGED
@@ -1,11 +1,41 @@
|
|
1
|
+
# 1.7.4 (2020-10-09)
|
2
|
+
|
3
|
+
* Rework how the default `retry_limit` is calculated
|
4
|
+
* Numerous documentation updates
|
5
|
+
|
6
|
+
# 1.7.3 (2019-11-21)
|
7
|
+
|
8
|
+
* Do not crash if job class is not found on the resque-web server
|
9
|
+
|
10
|
+
# 1.7.2 (2019-11-21)
|
11
|
+
|
12
|
+
* Address part 2 of issue #158
|
13
|
+
|
14
|
+
# 1.7.1 (2019-07-10)
|
15
|
+
|
16
|
+
* Prevent `NoMethodError` when calculating `retry_delay`
|
17
|
+
|
18
|
+
# 1.7.0 (2019-06-15)
|
19
|
+
|
20
|
+
!!! [Potential] breaking changes -- details below !!!
|
21
|
+
|
22
|
+
* Remove support for `args_for_retry` -- it has been deprecated for almost 5
|
23
|
+
years
|
24
|
+
* Work w/ shallow-clone(s) of `args` in `MultipleWithRetrySuppression#save` and
|
25
|
+
`Retry.retry_args`
|
26
|
+
* Remove deprecated options from `Gem::Specification`
|
27
|
+
* Clean-up formatting in HISTORY.md
|
28
|
+
|
1
29
|
# 1.6.0 (2019-04-21)
|
2
30
|
|
3
|
-
* Clean-up / refactoring in preparation for a release (`ruby` deprecations,
|
31
|
+
* Clean-up / refactoring in preparation for a release (`ruby` deprecations,
|
32
|
+
etc.)
|
4
33
|
* Loosen version requirement to allow resque v2.0 and up (@peret)
|
5
34
|
|
6
35
|
# 1.5.3 (2018-11-26)
|
7
36
|
|
8
|
-
* Monkey patch in the `requeue_queue` method onto the `Resque::Failure` backend
|
37
|
+
* Monkey patch in the `requeue_queue` method onto the `Resque::Failure` backend
|
38
|
+
(this _should_ be a temporary fix)
|
9
39
|
|
10
40
|
# 1.5.2 (2018-07-16)
|
11
41
|
|
@@ -14,11 +44,15 @@
|
|
14
44
|
|
15
45
|
# 1.5.1 (2018-01-07)
|
16
46
|
|
17
|
-
* Added build support for `ruby-2.2.x`, `ruby-2.3.x`, `ruby-2.4.x` and
|
18
|
-
|
47
|
+
* Added build support for `ruby-2.2.x`, `ruby-2.3.x`, `ruby-2.4.x` and
|
48
|
+
`ruby-2.5.x`
|
49
|
+
* Dropped build support for `ruby-1.9.3` and `ruby-2.0.0` (these versions are
|
50
|
+
no unsupported)
|
19
51
|
* Fix some deprecation warnings in tests
|
20
|
-
* Feature: If no exact exception class is present in `@retry_exceptions` hash,
|
21
|
-
|
52
|
+
* Feature: If no exact exception class is present in `@retry_exceptions` hash,
|
53
|
+
try to find closest superclass (@fanfilmu)
|
54
|
+
* Feature: When running Resque inline, explicitly don't try to retry, don't
|
55
|
+
touch Redis (@michaelglass)
|
22
56
|
|
23
57
|
# 1.5.0 (2015-10-24)
|
24
58
|
|
@@ -40,25 +74,35 @@
|
|
40
74
|
## 1.3.0 (2014-07-25)
|
41
75
|
|
42
76
|
* Adjust gem dependency on `resque-scheduler` to ~> 3.0
|
43
|
-
* Deprecated: `args_for_retry` in favor of `retry_args` (will output deprecation
|
44
|
-
|
77
|
+
* Deprecated: `args_for_retry` in favor of `retry_args` (will output deprecation
|
78
|
+
warnings if your using the older method).
|
79
|
+
* Feature: Allow changing the args for a given exception using
|
80
|
+
`retry_args_for_exception` (@jonp)
|
45
81
|
* Feature: Allow setting `@expire_retry_key_after` on the fly (@orenmazor)
|
46
82
|
|
47
83
|
## 1.2.1 (2014-06-09)
|
48
84
|
|
49
|
-
* Fixed Kernel.rand: "invalid argument - 0.0 (ArgumentError)" error with
|
85
|
+
* Fixed Kernel.rand: "invalid argument - 0.0 (ArgumentError)" error with
|
86
|
+
"ExponentialBackoff" (on "Rubinius") when `retry_delay_multiplicand_min` and
|
87
|
+
`retry_delay_multiplicand_max` were the same value (@saizai)
|
50
88
|
|
51
89
|
## 1.2.0 (2014-05-19)
|
52
90
|
|
53
|
-
* Fixed scenario where job does not get retried correctly when `perform` is not
|
54
|
-
|
55
|
-
* Feature:
|
91
|
+
* Fixed scenario where job does not get retried correctly when `perform` is not
|
92
|
+
called as expected.
|
93
|
+
* Feature: Optional `@expire_retry_key_after` settings; expires retry counters
|
94
|
+
from redis to save you cleaning up stale state.
|
95
|
+
* Feature: Expose inner-workings of plugin through debug messages using
|
96
|
+
`Resque.logger` (when logging level is Logger:DEBUG).
|
56
97
|
|
57
98
|
## 1.1.4 (2014-03-17)
|
58
99
|
|
59
|
-
* Fixed displaying retry information in resque web interface, caused by
|
60
|
-
|
61
|
-
* Feature: Allow
|
100
|
+
* Fixed displaying retry information in resque web interface, caused by
|
101
|
+
`Resque::Helpers` being deprecated.
|
102
|
+
* Feature: Allow `@fatal_exceptions` as inverse of `@retry_exceptions`, when
|
103
|
+
a fatal exception is raised the job will be immediately fail.
|
104
|
+
* Feature: Allow a random retry delay (within a range) when using exponential
|
105
|
+
backoff strategy.
|
62
106
|
|
63
107
|
## 1.1.1 (2014-03-12)
|
64
108
|
|
@@ -67,7 +111,8 @@
|
|
67
111
|
## 1.1.0 (2014-03-12)
|
68
112
|
|
69
113
|
* Remove dependence on `Resque::Helpers`, will be removed in Resque 2.0
|
70
|
-
* Use SHA1 for default `#retry_identifier` to prevents issues with long args
|
114
|
+
* Use SHA1 for default `#retry_identifier` to prevents issues with long args
|
115
|
+
gobbling space.
|
71
116
|
* Minimum version of Resque is now ~> 1.25
|
72
117
|
|
73
118
|
## 1.0.0 (2012-09-07)
|
@@ -75,12 +120,16 @@
|
|
75
120
|
** !!! WARNING !!! INCLUDES NON-BACKWARDS COMPATIBLE CHANGES **
|
76
121
|
|
77
122
|
* Fixed issues related to infinite job retries and v1.20.0 of resque.
|
78
|
-
* Minimum gem dependency versions changed: resque >= 1.10.0, resque-scheduler
|
79
|
-
|
80
|
-
*
|
123
|
+
* Minimum gem dependency versions changed: resque >= 1.10.0, resque-scheduler
|
124
|
+
>= 1.9.9
|
125
|
+
* Feature: Setting `@retry_job_delegate` allows you to separate the original job
|
126
|
+
from a the retry job. (@tanob/@jniesen)
|
127
|
+
* Web interface will work without needing to `require` your job code. (n.b.
|
128
|
+
less details available via web).
|
81
129
|
* IMPORTANT: `#identifier` method has been namespaced to `#retry_identifier`.
|
82
130
|
* Bugfix: `Remove` button on retry web interface was not working.
|
83
|
-
* Feature: Allow `tagging` exceptions with a module instead of an exception
|
131
|
+
* Feature: Allow `tagging` exceptions with a module instead of an exception
|
132
|
+
class. (@tils - Tilmann Singer)
|
84
133
|
|
85
134
|
## 0.2.2 (2011-12-08)
|
86
135
|
|
@@ -88,7 +137,8 @@
|
|
88
137
|
|
89
138
|
## 0.2.1 (2011-11-23)
|
90
139
|
|
91
|
-
* Bugfix: Fixed error when we tried to parse a number/string as JSON on the
|
140
|
+
* Bugfix: Fixed error when we tried to parse a number/string as JSON on the
|
141
|
+
reque-retry web interface.
|
92
142
|
|
93
143
|
## 0.2.0 (2011-11-22)
|
94
144
|
|
@@ -98,9 +148,10 @@
|
|
98
148
|
PREVIOUSLY: 0 == infinite retries.
|
99
149
|
NOW: -1 == infinite retries; 0 == means never retry.
|
100
150
|
|
101
|
-
* Bugfix: `#redis_retry_key` incorrectly built key when custom identifier was
|
151
|
+
* Bugfix: `#redis_retry_key` incorrectly built key when custom identifier was
|
152
|
+
used. (Bogdan Gusiev)
|
102
153
|
* Feature: Ability to sleep worker after re-queuing a job, may be used to bias
|
103
|
-
|
154
|
+
against the same worker from picking up the job again. (Michael Keirnan)
|
104
155
|
* Feature: Ability to remove retry jobs using resque-web. (Thiago Morello)
|
105
156
|
* Added example demo application.
|
106
157
|
* Added Bundler `Gemfile`.
|
@@ -130,7 +181,8 @@
|
|
130
181
|
## 0.0.2 (2010-05-06)
|
131
182
|
|
132
183
|
* Bugfix: Were calling non-existent method to delete redis key.
|
133
|
-
* Delay no-longer falls back to `sleep`. resque-scheduler is a required
|
184
|
+
* Delay no-longer falls back to `sleep`. resque-scheduler is a required
|
185
|
+
dependancy.
|
134
186
|
* Redis key doesn't include ending colon `:` if no args were passed to the job.
|
135
187
|
|
136
188
|
## 0.0.1 (2010-04-27)
|
data/README.md
CHANGED
@@ -231,8 +231,8 @@ class ExampleJob
|
|
231
231
|
extend Resque::Plugins::Retry
|
232
232
|
@queue = :testing
|
233
233
|
|
234
|
-
def self.retry_delay(
|
235
|
-
if
|
234
|
+
def self.retry_delay(exception_class)
|
235
|
+
if exception_class == SocketError
|
236
236
|
10
|
237
237
|
else
|
238
238
|
1
|
@@ -359,7 +359,12 @@ You may also want to specify different retry delays for different exception
|
|
359
359
|
types. You may optionally set `@retry_exceptions` to a hash where the keys are
|
360
360
|
your specific exception classes to retry on, and the values are your retry
|
361
361
|
delays in seconds or an array of retry delays to be used similar to exponential
|
362
|
-
backoff.
|
362
|
+
backoff. `resque-retry` will attempt to determine your retry strategy's
|
363
|
+
`@retry_limit` based on your specified `@retry_exceptions`. If, however, you
|
364
|
+
define `@retry_limit` explicitly, you should define `@retry_limit` such that it
|
365
|
+
allows for your retry strategies to complete. If your `@retry_limit` is less
|
366
|
+
than the number of desired retry attempts defined in `@retry_exceptions`, your
|
367
|
+
job will only retry `@retry_limit` times.
|
363
368
|
```ruby
|
364
369
|
class DeliverSMS
|
365
370
|
extend Resque::Plugins::Retry
|
@@ -374,9 +379,15 @@ end
|
|
374
379
|
```
|
375
380
|
|
376
381
|
In the above example, Resque would retry any `DeliverSMS` jobs which throw a
|
377
|
-
`NetworkError` or `SystemCallError`.
|
378
|
-
|
379
|
-
|
382
|
+
`NetworkError` or `SystemCallError`. The `@retry_limit` would be inferred to be
|
383
|
+
2 based on the longest retry strategy defined in `@retry_exceptions`. If the job
|
384
|
+
throws a `NetworkError` it will be retried 30 seconds later with a subsequent
|
385
|
+
retry 30 seconds after that. If it throws a `SystemCallError` it will first
|
386
|
+
retry 120 seconds later then a subsequent retry attempt 240 seconds later. If
|
387
|
+
the job fails due to a `NetworkError`, Resque would retry the job in 30 seconds.
|
388
|
+
If the job fails a second time, this time due to a `SystemCallError`, the next
|
389
|
+
retry would occur 240 seconds later as specified in the `SystemCallError`
|
390
|
+
array defined in `@retry_exceptions`.
|
380
391
|
|
381
392
|
### <a name="fail_fast"></a> Fail Fast For Specific Exceptions
|
382
393
|
|
@@ -511,7 +522,7 @@ class ExampleJob
|
|
511
522
|
|
512
523
|
def self.work(*args)
|
513
524
|
user_id, user_mode, record_id = *args
|
514
|
-
|
525
|
+
|
515
526
|
Resque.enqueue_to(
|
516
527
|
target_queue_for_args(user_id, user_mode, record_id),
|
517
528
|
self,
|
@@ -531,7 +542,7 @@ class ExampleJob
|
|
531
542
|
user_id, user_mode, record_id = *args
|
532
543
|
|
533
544
|
if user_mode
|
534
|
-
'high
|
545
|
+
'high'
|
535
546
|
else
|
536
547
|
'low'
|
537
548
|
end
|
@@ -585,7 +596,7 @@ end
|
|
585
596
|
|
586
597
|
This saves you from having to run a "house cleaning" or "errand" job.
|
587
598
|
|
588
|
-
The
|
599
|
+
The expiry timeout is "pushed forward" or "touched" after each failure to
|
589
600
|
ensure it's not expired too soon.
|
590
601
|
|
591
602
|
### <a name="callbacks"></a> Try Again and Give Up Callbacks
|
data/lib/resque-retry/server.rb
CHANGED
@@ -66,15 +66,23 @@ module ResqueRetry
|
|
66
66
|
# cancels job retry
|
67
67
|
def cancel_retry(job)
|
68
68
|
klass = get_class(job)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
if klass
|
70
|
+
retry_key = retry_key_for_job(job)
|
71
|
+
Resque.remove_delayed(klass, *job['args'])
|
72
|
+
Resque.redis.del("failure-#{retry_key}")
|
73
|
+
Resque.redis.del(retry_key)
|
74
|
+
else
|
75
|
+
raise 'cannot cancel, job not found'
|
76
|
+
end
|
73
77
|
end
|
74
78
|
|
75
79
|
private
|
76
80
|
def get_class(job)
|
77
|
-
|
81
|
+
begin
|
82
|
+
Resque::Job.new(nil, nil).constantize(job['class'])
|
83
|
+
rescue
|
84
|
+
nil
|
85
|
+
end
|
78
86
|
end
|
79
87
|
end
|
80
88
|
|
data/lib/resque-retry/version.rb
CHANGED
@@ -27,7 +27,9 @@ module Resque
|
|
27
27
|
#
|
28
28
|
# @api private
|
29
29
|
def save
|
30
|
-
|
30
|
+
args = args_from(payload)
|
31
|
+
|
32
|
+
log_message 'failure backend save', args, exception
|
31
33
|
|
32
34
|
retryable = retryable?
|
33
35
|
job_being_retried = retryable && retrying?
|
@@ -35,7 +37,7 @@ module Resque
|
|
35
37
|
if !job_being_retried
|
36
38
|
log_message(
|
37
39
|
"#{retryable ? '' : 'non-'}retryable job is not being retried - sending failure to superclass",
|
38
|
-
|
40
|
+
args,
|
39
41
|
exception
|
40
42
|
)
|
41
43
|
|
@@ -44,7 +46,7 @@ module Resque
|
|
44
46
|
elsif retry_delay > 0
|
45
47
|
log_message(
|
46
48
|
"retry_delay: #{retry_delay} > 0 - saving details in Redis",
|
47
|
-
|
49
|
+
args,
|
48
50
|
exception
|
49
51
|
)
|
50
52
|
|
@@ -67,7 +69,7 @@ module Resque
|
|
67
69
|
else
|
68
70
|
log_message(
|
69
71
|
"retry_delay: #{retry_delay} <= 0 - ignoring",
|
70
|
-
|
72
|
+
args,
|
71
73
|
exception
|
72
74
|
)
|
73
75
|
end
|
@@ -100,7 +102,7 @@ module Resque
|
|
100
102
|
protected
|
101
103
|
|
102
104
|
def args_from(payload)
|
103
|
-
(payload || {})['args']
|
105
|
+
(payload || {})['args'].dup
|
104
106
|
end
|
105
107
|
|
106
108
|
def cleanup_retry_failure_log!
|
@@ -80,10 +80,11 @@ module Resque
|
|
80
80
|
|
81
81
|
# Selects the delay from the backoff strategy
|
82
82
|
#
|
83
|
+
# @param _ [Exception] unused exception argument for signature parity
|
83
84
|
# @return [Number] seconds to delay until the next retry.
|
84
85
|
#
|
85
86
|
# @api private
|
86
|
-
def retry_delay
|
87
|
+
def retry_delay(_ = nil)
|
87
88
|
delay = backoff_strategy[retry_attempt] || backoff_strategy.last
|
88
89
|
# if the values are the same don't bother generating a random number, if
|
89
90
|
# the delta is zero, some platforms will raise an error
|
data/lib/resque/plugins/retry.rb
CHANGED
@@ -107,11 +107,27 @@ module Resque
|
|
107
107
|
# A retry limit of 0 will *never* retry.
|
108
108
|
# A retry limit of -1 or below will retry forever.
|
109
109
|
#
|
110
|
+
# The default value is: `1` or in the case of where `@retry_exceptions` is
|
111
|
+
# specified, and it contains one or more `Array` values, the maximum
|
112
|
+
# length will be used (e.g. `@retry_exceptions = { NetworkError => 30, SystemCallError => [120, 240] }`
|
113
|
+
# would return `2` because `SystemCallError` _should_ be attempted at
|
114
|
+
# least twice to respect the specified configuration).
|
115
|
+
#
|
110
116
|
# @return [Fixnum]
|
111
117
|
#
|
112
118
|
# @api public
|
113
119
|
def retry_limit
|
114
|
-
@retry_limit ||=
|
120
|
+
@retry_limit ||= begin
|
121
|
+
default_retry_limit = 1
|
122
|
+
if instance_variable_defined?(:@retry_exceptions) && @retry_exceptions.is_a?(Hash)
|
123
|
+
@retry_exceptions.values.each do |value|
|
124
|
+
if value.is_a?(Array) && value.length > default_retry_limit
|
125
|
+
default_retry_limit = value.length
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
default_retry_limit
|
130
|
+
end
|
115
131
|
end
|
116
132
|
|
117
133
|
# Number of retry attempts used to try and perform the job
|
@@ -135,9 +151,13 @@ module Resque
|
|
135
151
|
#
|
136
152
|
# @api public
|
137
153
|
def retry_delay(exception_class = nil)
|
138
|
-
if
|
154
|
+
if \
|
155
|
+
!exception_class.nil? && \
|
156
|
+
instance_variable_defined?(:@retry_exceptions) && \
|
157
|
+
@retry_exceptions.is_a?(Hash)
|
139
158
|
delay = @retry_exceptions[exception_class] ||= begin
|
140
|
-
relevant_definitions =
|
159
|
+
relevant_definitions = \
|
160
|
+
@retry_exceptions.select { |ex| exception_class <= ex }
|
141
161
|
relevant_definitions.any? ? relevant_definitions.sort.first[1] : 0
|
142
162
|
end
|
143
163
|
# allow an array of delays.
|
@@ -186,15 +206,7 @@ module Resque
|
|
186
206
|
#
|
187
207
|
# @api public
|
188
208
|
def retry_args(*args)
|
189
|
-
|
190
|
-
# invoke it, but warn that it is deprecated (and will be removed in a
|
191
|
-
# future revision)
|
192
|
-
if respond_to?(:args_for_retry)
|
193
|
-
warn "`Resque::Plugins::Retry#args_for_retry` is deprecated, please use `Resque::Plugins::Retry#retry_args` instead."
|
194
|
-
args_for_retry(*args)
|
195
|
-
else
|
196
|
-
args
|
197
|
-
end
|
209
|
+
args.dup
|
198
210
|
end
|
199
211
|
|
200
212
|
# @abstract
|
@@ -460,7 +472,8 @@ module Resque
|
|
460
472
|
# set/update the "retry_key" expiration
|
461
473
|
if expire_retry_key_after
|
462
474
|
log_message "updating expiration for retry key: #{retry_key}", args
|
463
|
-
|
475
|
+
exception_class = Object.const_get(args[0]) rescue nil
|
476
|
+
Resque.redis.expire(retry_key, retry_delay(exception_class) + expire_retry_key_after)
|
464
477
|
end
|
465
478
|
end
|
466
479
|
|
data/resque-retry.gemspec
CHANGED
@@ -128,4 +128,11 @@ class ExponentialBackoffTest < Minitest::Test
|
|
128
128
|
assert_equal 4, Resque.info[:failed], 'failed jobs'
|
129
129
|
assert_equal 0, Resque.info[:pending], 'pending jobs'
|
130
130
|
end
|
131
|
+
|
132
|
+
def test_backoff_with_expiration
|
133
|
+
Resque.redis.expects(:expire)
|
134
|
+
|
135
|
+
Resque.enqueue(ExponentialBackoffWithExpiryJob)
|
136
|
+
perform_next_job(@worker)
|
137
|
+
end
|
131
138
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class RetryExceptionDelayTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
Resque.redis.flushall
|
6
6
|
@worker = Resque::Worker.new(:testing)
|
@@ -43,4 +43,12 @@ class RetryExeptionDelayTest < Minitest::Test
|
|
43
43
|
assert_in_delta (start_time + 10), delayed[1], 1.00, '2nd retry delay timestamp'
|
44
44
|
assert_in_delta (start_time + 15), delayed[2], 1.00, '3rd retry delay timestamp'
|
45
45
|
end
|
46
|
+
|
47
|
+
def test_retry_delay_per_exception_multiple_delay_no_retry_limit_specified
|
48
|
+
# For this job-type there are 3 `Exception` types defined: `Exception`,
|
49
|
+
# `StandardError` and `Timeout::Error` -- their array-lengths are are 1, 3
|
50
|
+
# and 5 (respectively). We expect the `retry_limit` to default to the
|
51
|
+
# maximum length of the `Array` of delays or 1 (in this case: 5)
|
52
|
+
assert_equal 5, PerExceptionClassRetryCountArrayNoRetryLimitSpecifiedJob.retry_limit
|
53
|
+
end
|
46
54
|
end
|
data/test/retry_test.rb
CHANGED
@@ -55,13 +55,6 @@ class RetryTest < Minitest::Test
|
|
55
55
|
assert_equal test_args, job['args']
|
56
56
|
end
|
57
57
|
|
58
|
-
def test_job_args_can_be_modified_by_overriding_args_for_retry
|
59
|
-
Resque.enqueue(DeprecatedRetryWithModifiedArgsJob)
|
60
|
-
DeprecatedRetryWithModifiedArgsJob.expects(:warn)
|
61
|
-
DeprecatedRetryWithModifiedArgsJob.expects(:args_for_retry)
|
62
|
-
perform_next_job(@worker)
|
63
|
-
end
|
64
|
-
|
65
58
|
def test_job_args_can_be_modified_by_overriding_retry_args
|
66
59
|
Resque.enqueue(RetryWithModifiedArgsJob)
|
67
60
|
RetryWithModifiedArgsJob.expects(:retry_args)
|
@@ -278,6 +271,7 @@ class RetryTest < Minitest::Test
|
|
278
271
|
end
|
279
272
|
|
280
273
|
def test_retry_delay
|
274
|
+
assert_equal 0, NoRetryDelayJob.retry_delay
|
281
275
|
assert_equal 3, NormalRetryCountJob.retry_delay
|
282
276
|
assert_equal 7, PerExceptionClassRetryCountJob.retry_delay(StandardError)
|
283
277
|
assert_equal 7, PerExceptionClassRetryCountJob.retry_delay(CustomException)
|
@@ -293,6 +287,12 @@ class RetryTest < Minitest::Test
|
|
293
287
|
perform_next_job(@worker)
|
294
288
|
end
|
295
289
|
|
290
|
+
def test_expire_key_set_with_retry_exceptions
|
291
|
+
Resque.redis.expects(:expire).once.with(ExpiringJobWithRetryExceptions.redis_retry_key(StandardError), 17)
|
292
|
+
Resque.enqueue(ExpiringJobWithRetryExceptions, StandardError)
|
293
|
+
perform_next_job(@worker)
|
294
|
+
end
|
295
|
+
|
296
296
|
def test_expire_key_setting_on_the_fly
|
297
297
|
retry_key = 'resque-retry:FailFiveTimesWithCustomExpiryJob'
|
298
298
|
|
data/test/test_jobs.rb
CHANGED
@@ -7,7 +7,7 @@ class NoRetryJob
|
|
7
7
|
@queue = :testing
|
8
8
|
|
9
9
|
def self.perform(*args)
|
10
|
-
raise
|
10
|
+
raise 'error'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -28,6 +28,17 @@ class ExpiringJob
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
class ExpiringJobWithRetryExceptions
|
32
|
+
extend Resque::Plugins::Retry
|
33
|
+
|
34
|
+
@queue = :testing
|
35
|
+
@expire_retry_key_after = 10
|
36
|
+
@retry_exceptions = { StandardError => 7 }
|
37
|
+
|
38
|
+
def self.perform(*args)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
31
42
|
class RetryDefaultSettingsJob
|
32
43
|
extend Resque::Plugins::Retry
|
33
44
|
@queue = :testing
|
@@ -146,14 +157,6 @@ class InheritTestWithMoreExtraJob < InheritTestWithExtraJob
|
|
146
157
|
end
|
147
158
|
end
|
148
159
|
|
149
|
-
class DeprecatedRetryWithModifiedArgsJob < RetryDefaultsJob
|
150
|
-
@queue = :testing
|
151
|
-
|
152
|
-
def self.args_for_retry(*args)
|
153
|
-
# NOTE: implementation is irrelevant we only care that it's invoked
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
160
|
class RetryWithModifiedArgsJob < RetryDefaultsJob
|
158
161
|
@queue = :testing
|
159
162
|
|
@@ -251,6 +254,12 @@ class ExponentialBackoffWithRetryDelayMultiplicandMinAndMaxJob < RetryDefaultsJo
|
|
251
254
|
@retry_delay_multiplicand_max = 3.0
|
252
255
|
end
|
253
256
|
|
257
|
+
class ExponentialBackoffWithExpiryJob < RetryDefaultsJob
|
258
|
+
extend Resque::Plugins::ExponentialBackoff
|
259
|
+
@queue = :testing
|
260
|
+
@expire_retry_key_after = 60 * 60
|
261
|
+
end
|
262
|
+
|
254
263
|
class InvalidRetryDelayMaxConfigurationJob
|
255
264
|
@queue = :testing
|
256
265
|
@retry_delay_multiplicand_max = 0.9
|
@@ -534,6 +543,13 @@ class CustomRetryIdentifierFailingJob
|
|
534
543
|
end
|
535
544
|
end
|
536
545
|
|
546
|
+
class NoRetryDelayJob
|
547
|
+
extend Resque::Plugins::Retry
|
548
|
+
|
549
|
+
@queue = :testing
|
550
|
+
@retry_exceptions = {}
|
551
|
+
end
|
552
|
+
|
537
553
|
class NormalRetryCountJob
|
538
554
|
extend Resque::Plugins::Retry
|
539
555
|
|
@@ -566,6 +582,17 @@ class PerExceptionClassRetryCountArrayJob
|
|
566
582
|
end
|
567
583
|
end
|
568
584
|
|
585
|
+
class PerExceptionClassRetryCountArrayNoRetryLimitSpecifiedJob
|
586
|
+
extend Resque::Plugins::Retry
|
587
|
+
|
588
|
+
@queue = :testing
|
589
|
+
@retry_exceptions = { Exception => 11, RuntimeError => [5, 10, 15], Timeout::Error => [2, 4, 6, 8, 10] }
|
590
|
+
|
591
|
+
def self.perform
|
592
|
+
raise RuntimeError, 'I always fail with a RuntimeError'
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
569
596
|
# We can't design a job to fail during connect, see perform_next_job_fail_on_reconnect
|
570
597
|
class FailsDuringConnectJob < RetryDefaultsJob
|
571
598
|
@queue = :testing
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Antins
|
8
8
|
- Ryan Carver
|
9
9
|
- Jonathan W. Zaleski
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: resque
|
@@ -208,7 +208,7 @@ homepage: http://github.com/lantins/resque-retry
|
|
208
208
|
licenses:
|
209
209
|
- MIT
|
210
210
|
metadata: {}
|
211
|
-
post_install_message:
|
211
|
+
post_install_message:
|
212
212
|
rdoc_options: []
|
213
213
|
require_paths:
|
214
214
|
- lib
|
@@ -223,8 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
227
|
-
signing_key:
|
226
|
+
rubygems_version: 3.1.4
|
227
|
+
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: A resque plugin; provides retry, delay and exponential backoff support for
|
230
230
|
resque jobs.
|