resque-retry 1.7.4 → 1.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +24 -0
- data/.gitignore +2 -0
- data/HISTORY.md +5 -0
- data/lib/resque-retry/version.rb +1 -1
- data/lib/resque/failure/multiple_with_retry_suppression.rb +20 -9
- data/test/multiple_failure_test.rb +19 -3
- data/test/test_helper.rb +22 -18
- metadata +4 -4
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a29581b3dc95632cee77ae024594ec6371f180aa2c321f2ab8867ea9b0a98fd
|
4
|
+
data.tar.gz: 6c833821432ee8fbaa5d701bf93f0ce85655a88273f550cd6fb52f1556ac2f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 916ae887694f4e1cf3b7acba5c444c59983d031f16f3b811b7535cd2c2bd39bfcea98ca095897558151156c76ff5f3e909600ed5150582da508aafa91242c1d9
|
7
|
+
data.tar.gz: ed7eaef67c2fc766b1bf188c8904b354d05079d591dd6cfb8c9c4191e773ece241fdf3ce37c1333300d69d1bc6b40a73deaf39956c6832919a173fc8e7f8fba3
|
@@ -0,0 +1,24 @@
|
|
1
|
+
on: [push, pull_request]
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
services:
|
7
|
+
redis:
|
8
|
+
image: redis
|
9
|
+
ports:
|
10
|
+
- 6379:6379
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby-version: [2.7, 2.6, 2.5, 2.4, 2.3]
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby-version }}
|
21
|
+
- name: Install dependencies
|
22
|
+
run: bundle install
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/HISTORY.md
CHANGED
data/lib/resque-retry/version.rb
CHANGED
@@ -42,10 +42,25 @@ module Resque
|
|
42
42
|
)
|
43
43
|
|
44
44
|
cleanup_retry_failure_log!
|
45
|
-
super
|
46
|
-
|
45
|
+
return super
|
46
|
+
end
|
47
|
+
|
48
|
+
# some plugins define retry_delay and have it take no arguments, so rather than break those,
|
49
|
+
# we'll just check here to see whether it takes the additional exception class argument or not
|
50
|
+
# we also allow all job args to be passed to a custom `retry_delay` method
|
51
|
+
retry_delay_arity = klass.method(:retry_delay).arity
|
52
|
+
|
53
|
+
calculated_retry_delay = if [-2, 2].include?(retry_delay_arity)
|
54
|
+
klass.retry_delay(exception.class, *args)
|
55
|
+
elsif [-1, 1].include?(retry_delay_arity)
|
56
|
+
klass.retry_delay(exception.class)
|
57
|
+
else
|
58
|
+
klass.retry_delay
|
59
|
+
end
|
60
|
+
|
61
|
+
if calculated_retry_delay > 0
|
47
62
|
log_message(
|
48
|
-
"retry_delay: #{
|
63
|
+
"retry_delay: #{calculated_retry_delay} > 0 - saving details in Redis",
|
49
64
|
args,
|
50
65
|
exception
|
51
66
|
)
|
@@ -63,12 +78,12 @@ module Resque
|
|
63
78
|
|
64
79
|
Resque.redis.setex(
|
65
80
|
failure_key,
|
66
|
-
2 *
|
81
|
+
2 * calculated_retry_delay,
|
67
82
|
data
|
68
83
|
)
|
69
84
|
else
|
70
85
|
log_message(
|
71
|
-
"retry_delay: #{
|
86
|
+
"retry_delay: #{calculated_retry_delay} <= 0 - ignoring",
|
72
87
|
args,
|
73
88
|
exception
|
74
89
|
)
|
@@ -117,10 +132,6 @@ module Resque
|
|
117
132
|
Resque::Job.new(nil, nil).constantize(payload['class'])
|
118
133
|
end
|
119
134
|
|
120
|
-
def retry_delay
|
121
|
-
klass.retry_delay
|
122
|
-
end
|
123
|
-
|
124
135
|
def retry_key
|
125
136
|
klass.redis_retry_key(*payload['args'])
|
126
137
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative './test_helper'
|
2
2
|
|
3
3
|
# Mock failure backend for testing MultipleWithRetrySuppression
|
4
4
|
class MockFailureBackend < Resque::Failure::Base
|
@@ -25,8 +25,8 @@ class MultipleFailureTest < Minitest::Test
|
|
25
25
|
Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression
|
26
26
|
end
|
27
27
|
|
28
|
-
def failure_key_for(klass)
|
29
|
-
|
28
|
+
def failure_key_for(klass, *args)
|
29
|
+
Resque::Failure::MultipleWithRetrySuppression.failure_key(klass.redis_retry_key(args))
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_failure_is_passed_on_when_job_class_not_found
|
@@ -53,6 +53,22 @@ class MultipleFailureTest < Minitest::Test
|
|
53
53
|
assert Resque.redis.exists(key)
|
54
54
|
end
|
55
55
|
|
56
|
+
def test_retry_delay_is_calculated_with_custom_calculation
|
57
|
+
delay = 5
|
58
|
+
Resque.enqueue(DynamicDelayedJobOnExceptionAndArgs, delay.to_s)
|
59
|
+
perform_next_job(@worker)
|
60
|
+
|
61
|
+
key = failure_key_for(DynamicDelayedJobOnExceptionAndArgs, delay.to_s)
|
62
|
+
ttl = Resque.redis.ttl(key)
|
63
|
+
assert Resque.redis.exists(key)
|
64
|
+
assert MockFailureBackend.errors.size == 0
|
65
|
+
|
66
|
+
# expiration on failure_key is set to 2x the delay
|
67
|
+
# to ensure the customized delay is properly calculated using
|
68
|
+
# dynamic retry_delay method on the job
|
69
|
+
assert ttl > delay && delay <= (delay * 2)
|
70
|
+
end
|
71
|
+
|
56
72
|
def test_retry_key_splatting_args
|
57
73
|
# were expecting this to be called three times:
|
58
74
|
# - once when we queue the job to try again
|
data/test/test_helper.rb
CHANGED
@@ -20,25 +20,29 @@ require 'mocha/setup'
|
|
20
20
|
require 'resque-retry'
|
21
21
|
require dir + '/test_jobs'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
if ENV['CI'] != 'true'
|
24
|
+
# make sure we can run redis-server
|
25
|
+
if !system('which redis-server')
|
26
|
+
puts '', "** `redis-server` was not found in your PATH"
|
27
|
+
abort ''
|
28
|
+
end
|
28
29
|
|
29
|
-
# make sure we can shutdown the server using cli.
|
30
|
-
if !system('which redis-cli')
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
# make sure we can shutdown the server using cli.
|
31
|
+
if !system('which redis-cli')
|
32
|
+
puts '', "** `redis-cli` was not found in your PATH"
|
33
|
+
abort ''
|
34
|
+
end
|
34
35
|
|
35
|
-
# This code is run after all the tests have finished running to ensure that the
|
36
|
-
# Redis server is shutdowa
|
37
|
-
Minitest.after_run { `redis-cli -p 9736 shutdown nosave` }
|
36
|
+
# This code is run after all the tests have finished running to ensure that the
|
37
|
+
# Redis server is shutdowa
|
38
|
+
Minitest.after_run { `redis-cli -p 9736 shutdown nosave` }
|
38
39
|
|
39
|
-
puts "Starting redis for testing at localhost:9736..."
|
40
|
-
`redis-server #{dir}/redis-test.conf`
|
41
|
-
Resque.redis = '127.0.0.1:9736'
|
40
|
+
puts "Starting redis for testing at localhost:9736..."
|
41
|
+
`redis-server #{dir}/redis-test.conf`
|
42
|
+
Resque.redis = '127.0.0.1:9736'
|
43
|
+
else
|
44
|
+
Resque.redis = '127.0.0.1:6379'
|
45
|
+
end
|
42
46
|
|
43
47
|
# Test helpers
|
44
48
|
class Minitest::Test
|
@@ -65,11 +69,11 @@ class Minitest::Test
|
|
65
69
|
|
66
70
|
def delayed_jobs
|
67
71
|
# The double-checks here are so that we won't blow up if the config stops using redis-namespace
|
68
|
-
timestamps = Resque.redis.zrange("resque:delayed_queue_schedule", 0, -1) +
|
72
|
+
timestamps = Resque.redis.zrange("resque:delayed_queue_schedule", 0, -1) +
|
69
73
|
Resque.redis.zrange("delayed_queue_schedule", 0, -1)
|
70
74
|
|
71
75
|
delayed_jobs_as_json = timestamps.map do |timestamp|
|
72
|
-
Resque.redis.lrange("resque:delayed:#{timestamp}", 0, -1) +
|
76
|
+
Resque.redis.lrange("resque:delayed:#{timestamp}", 0, -1) +
|
73
77
|
Resque.redis.lrange("delayed:#{timestamp}", 0, -1)
|
74
78
|
end.flatten
|
75
79
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Antins
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: resque
|
@@ -161,8 +161,8 @@ executables: []
|
|
161
161
|
extensions: []
|
162
162
|
extra_rdoc_files: []
|
163
163
|
files:
|
164
|
+
- ".github/workflows/ci.yml"
|
164
165
|
- ".gitignore"
|
165
|
-
- ".travis.yml"
|
166
166
|
- Gemfile
|
167
167
|
- HISTORY.md
|
168
168
|
- LICENSE
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
226
|
+
rubygems_version: 3.2.22
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: A resque plugin; provides retry, delay and exponential backoff support for
|