resque-retry 1.7.4 → 1.7.6
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 +11 -0
- data/lib/resque-retry/version.rb +1 -1
- data/lib/resque/failure/multiple_with_retry_suppression.rb +31 -10
- data/test/multiple_failure_test.rb +33 -3
- data/test/test_helper.rb +24 -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: bcd42f2b0761226dd2cfa5f9c9d4ff336cda1be0f6acf972ae15cd553f88fa0b
|
4
|
+
data.tar.gz: d65b4261a3ff1068f9880739ea1f4647c10be957511840203331f714cb8281dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c8fccf7a670f1fc0246d7e8862941eae3fb2bda8ea4d11fb1bea2a5890ed1867f50ff9389a752f3383bf5383783b32e3f63c5ef623909a28aaeba62f4576a2
|
7
|
+
data.tar.gz: 8e3e0ed80d154282e6dddd85b8b7b95b22949d580ad6c0c7a0fc9c3a16475dca861320f919db0f2ddf6b8dca78e8bdd846a48b86db6a5761848d6d4fcb7012a4
|
@@ -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]
|
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
@@ -1,3 +1,14 @@
|
|
1
|
+
# 1.7.6 (2021-08-06)
|
2
|
+
|
3
|
+
* Fix Redis 4.3 breaking saving job failures with multiple failure backend
|
4
|
+
* Disable verbose logging by default during test-runs
|
5
|
+
* Remove support for ruby < 2.6
|
6
|
+
|
7
|
+
# 1.7.5 (2021-08-06)
|
8
|
+
|
9
|
+
* Support `retry_delay` methods with different arity
|
10
|
+
* Switch over to _GitHub_ CI for PR test-execution
|
11
|
+
|
1
12
|
# 1.7.4 (2020-10-09)
|
2
13
|
|
3
14
|
* Rework how the default `retry_limit` is calculated
|
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
|
@@ -132,7 +143,17 @@ module Resque
|
|
132
143
|
end
|
133
144
|
|
134
145
|
def retrying?
|
135
|
-
|
146
|
+
redis_key_exists?(retry_key)
|
147
|
+
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
def redis_key_exists?(key)
|
152
|
+
if Resque.redis.respond_to?(:exists?)
|
153
|
+
Resque.redis.exists?(key)
|
154
|
+
else
|
155
|
+
![false, 0].include?(Resque.redis.exists(key) || false)
|
156
|
+
end
|
136
157
|
end
|
137
158
|
end
|
138
159
|
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
|
@@ -141,6 +157,20 @@ class MultipleFailureTest < Minitest::Test
|
|
141
157
|
end
|
142
158
|
end
|
143
159
|
|
160
|
+
def test_redis_exists_returns_integer
|
161
|
+
Resque.enqueue(RetryDefaultsJob)
|
162
|
+
original = Redis.exists_returns_integer
|
163
|
+
Redis.exists_returns_integer = true
|
164
|
+
|
165
|
+
3.times do
|
166
|
+
perform_next_job(@worker)
|
167
|
+
end
|
168
|
+
|
169
|
+
Redis.exists_returns_integer = original
|
170
|
+
|
171
|
+
assert_equal 1, MockFailureBackend.errors.size
|
172
|
+
end
|
173
|
+
|
144
174
|
def teardown
|
145
175
|
Resque::Failure.backend = @old_failure_backend
|
146
176
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
dir = File.dirname(File.expand_path(__FILE__))
|
2
2
|
$LOAD_PATH.unshift dir + '/../lib'
|
3
|
+
|
3
4
|
$TESTING = true
|
5
|
+
$VERBOSE = ENV['VERBOSE'] != 'true' ? nil : true
|
4
6
|
|
5
7
|
# Run code coverage in MRI 1.9 only.
|
6
8
|
if RUBY_VERSION >= '1.9' && RUBY_ENGINE == 'ruby'
|
@@ -20,25 +22,29 @@ require 'mocha/setup'
|
|
20
22
|
require 'resque-retry'
|
21
23
|
require dir + '/test_jobs'
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
if ENV['CI'] != 'true'
|
26
|
+
# make sure we can run redis-server
|
27
|
+
if !system('which redis-server')
|
28
|
+
puts '', "** `redis-server` was not found in your PATH"
|
29
|
+
abort ''
|
30
|
+
end
|
28
31
|
|
29
|
-
# make sure we can shutdown the server using cli.
|
30
|
-
if !system('which redis-cli')
|
31
|
-
|
32
|
-
|
33
|
-
end
|
32
|
+
# make sure we can shutdown the server using cli.
|
33
|
+
if !system('which redis-cli')
|
34
|
+
puts '', "** `redis-cli` was not found in your PATH"
|
35
|
+
abort ''
|
36
|
+
end
|
34
37
|
|
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` }
|
38
|
+
# This code is run after all the tests have finished running to ensure that the
|
39
|
+
# Redis server is shutdowa
|
40
|
+
Minitest.after_run { `redis-cli -p 9736 shutdown nosave` }
|
38
41
|
|
39
|
-
puts "Starting redis for testing at localhost:9736..."
|
40
|
-
`redis-server #{dir}/redis-test.conf`
|
41
|
-
Resque.redis = '127.0.0.1:9736'
|
42
|
+
puts "Starting redis for testing at localhost:9736..."
|
43
|
+
`redis-server #{dir}/redis-test.conf`
|
44
|
+
Resque.redis = '127.0.0.1:9736'
|
45
|
+
else
|
46
|
+
Resque.redis = '127.0.0.1:6379'
|
47
|
+
end
|
42
48
|
|
43
49
|
# Test helpers
|
44
50
|
class Minitest::Test
|
@@ -65,11 +71,11 @@ class Minitest::Test
|
|
65
71
|
|
66
72
|
def delayed_jobs
|
67
73
|
# 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) +
|
74
|
+
timestamps = Resque.redis.zrange("resque:delayed_queue_schedule", 0, -1) +
|
69
75
|
Resque.redis.zrange("delayed_queue_schedule", 0, -1)
|
70
76
|
|
71
77
|
delayed_jobs_as_json = timestamps.map do |timestamp|
|
72
|
-
Resque.redis.lrange("resque:delayed:#{timestamp}", 0, -1) +
|
78
|
+
Resque.redis.lrange("resque:delayed:#{timestamp}", 0, -1) +
|
73
79
|
Resque.redis.lrange("delayed:#{timestamp}", 0, -1)
|
74
80
|
end.flatten
|
75
81
|
|
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.6
|
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
|