activejob-retry 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/active_job/retry.rb +2 -0
- data/lib/active_job/retry/version.rb +1 -1
- data/spec/retry_spec.rb +97 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a5bb27165e98b31cb047ca32c39686a3c65d999
|
4
|
+
data.tar.gz: 15d359bf6d2352c1b63f7f0729ce38ba12928a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95cb88b0dd261c6712fdd4063e94b0ada6b7854de361df98a424cee25f64fa01b967643a18665bf5120b2e5335339f1409d094b3e39f525538ec0f01bf6f1a3
|
7
|
+
data.tar.gz: 9c8c5fe96d0d16926db4d13c05a78db0977b2d045a26b3fdea62f8f79194cc4f293221c96d84e8b97bacab0d18260b1d74938ac2a2f33c865409a3a97eb4f0bc
|
data/Gemfile.lock
CHANGED
data/lib/active_job/retry.rb
CHANGED
data/spec/retry_spec.rb
CHANGED
@@ -12,7 +12,7 @@ RSpec.describe ActiveJob::Retry do
|
|
12
12
|
end.include(retry_instance)
|
13
13
|
end
|
14
14
|
|
15
|
-
describe '
|
15
|
+
describe 'constant strategy' do
|
16
16
|
let(:strategy) { :constant }
|
17
17
|
let(:options) { { limit: 10, delay: 5 } }
|
18
18
|
|
@@ -28,9 +28,17 @@ RSpec.describe ActiveJob::Retry do
|
|
28
28
|
to raise_error(ActiveJob::Retry::InvalidConfigurationError)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
context 'subclassing' do
|
33
|
+
let(:subclass) { Class.new(job) }
|
34
|
+
it 'has the ConstantBackoffStrategy' do
|
35
|
+
expect(subclass.backoff_strategy).
|
36
|
+
to be_a(ActiveJob::Retry::ConstantBackoffStrategy)
|
37
|
+
end
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
|
-
describe '
|
41
|
+
describe 'variable strategy' do
|
34
42
|
let(:strategy) { :variable }
|
35
43
|
let(:options) { { delays: [0, 5, 10, 60, 200] } }
|
36
44
|
|
@@ -46,9 +54,23 @@ RSpec.describe ActiveJob::Retry do
|
|
46
54
|
to raise_error(ActiveJob::Retry::InvalidConfigurationError)
|
47
55
|
end
|
48
56
|
end
|
57
|
+
|
58
|
+
context 'subclassing' do
|
59
|
+
let(:subclass) { Class.new(job) }
|
60
|
+
it 'has the VariableBackoffStrategy' do
|
61
|
+
expect(subclass.backoff_strategy).
|
62
|
+
to be_a(ActiveJob::Retry::VariableBackoffStrategy)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'allows overriding' do
|
66
|
+
subclass.include(described_class.new(strategy: :constant))
|
67
|
+
expect(subclass.backoff_strategy).
|
68
|
+
to be_a(ActiveJob::Retry::ConstantBackoffStrategy)
|
69
|
+
end
|
70
|
+
end
|
49
71
|
end
|
50
72
|
|
51
|
-
describe '
|
73
|
+
describe 'exponential strategy' do
|
52
74
|
let(:strategy) { :exponential }
|
53
75
|
let(:options) { { limit: 10 } }
|
54
76
|
|
@@ -73,6 +95,14 @@ RSpec.describe ActiveJob::Retry do
|
|
73
95
|
to raise_error(ActiveJob::Retry::InvalidConfigurationError)
|
74
96
|
end
|
75
97
|
end
|
98
|
+
|
99
|
+
context 'subclassing' do
|
100
|
+
let(:subclass) { Class.new(job) }
|
101
|
+
it 'has the ExponentialBackoffStrategy' do
|
102
|
+
expect(subclass.backoff_strategy).
|
103
|
+
to be_a(ActiveJob::Retry::ExponentialBackoffStrategy)
|
104
|
+
end
|
105
|
+
end
|
76
106
|
end
|
77
107
|
|
78
108
|
describe 'custom strategy' do
|
@@ -96,6 +126,13 @@ RSpec.describe ActiveJob::Retry do
|
|
96
126
|
it 'sets the backoff_strategy when it is valid' do
|
97
127
|
expect(job.backoff_strategy).to eq(CustomBackoffStrategy)
|
98
128
|
end
|
129
|
+
|
130
|
+
context 'subclassing' do
|
131
|
+
let(:subclass) { Class.new(job) }
|
132
|
+
it 'has the CustomBackoffStrategy' do
|
133
|
+
expect(subclass.backoff_strategy).to eq(strategy)
|
134
|
+
end
|
135
|
+
end
|
99
136
|
end
|
100
137
|
|
101
138
|
describe '#serialize' do
|
@@ -115,6 +152,26 @@ RSpec.describe ActiveJob::Retry do
|
|
115
152
|
before { instance.instance_variable_set(:@retry_attempt, 7) }
|
116
153
|
it { is_expected.to include('retry_attempt' => 7) }
|
117
154
|
end
|
155
|
+
|
156
|
+
context 'when inherited' do
|
157
|
+
let(:subclass) { Class.new(job) }
|
158
|
+
let(:instance) { subclass.new }
|
159
|
+
subject { instance.serialize }
|
160
|
+
|
161
|
+
context 'first instantiated' do
|
162
|
+
it { is_expected.to include('retry_attempt' => 1) }
|
163
|
+
end
|
164
|
+
|
165
|
+
context '1st attempt' do
|
166
|
+
before { instance.instance_variable_set(:@retry_attempt, 1) }
|
167
|
+
it { is_expected.to include('retry_attempt' => 1) }
|
168
|
+
end
|
169
|
+
|
170
|
+
context '7th attempt' do
|
171
|
+
before { instance.instance_variable_set(:@retry_attempt, 7) }
|
172
|
+
it { is_expected.to include('retry_attempt' => 7) }
|
173
|
+
end
|
174
|
+
end
|
118
175
|
end
|
119
176
|
|
120
177
|
describe '#deserialize' do
|
@@ -151,6 +208,43 @@ RSpec.describe ActiveJob::Retry do
|
|
151
208
|
its(:arguments) { is_expected.to eq(['arg1', { 'arg' => 2 }]) }
|
152
209
|
its(:retry_attempt) { is_expected.to eq(7) }
|
153
210
|
end
|
211
|
+
|
212
|
+
context 'when subclassing' do
|
213
|
+
let(:subclass) { Class.new(job) }
|
214
|
+
subject(:instance) { subclass.new }
|
215
|
+
before { instance.deserialize(job_data) }
|
216
|
+
before { instance.send(:deserialize_arguments_if_needed) }
|
217
|
+
|
218
|
+
context '1st attempt' do
|
219
|
+
let(:job_data) do
|
220
|
+
{
|
221
|
+
'job_class' => 'SomeJob',
|
222
|
+
'job_id' => 'uuid',
|
223
|
+
'arguments' => ['arg1', { 'arg' => 2 }],
|
224
|
+
'retry_attempt' => 1
|
225
|
+
}
|
226
|
+
end
|
227
|
+
|
228
|
+
its(:job_id) { is_expected.to eq('uuid') }
|
229
|
+
its(:arguments) { is_expected.to eq(['arg1', { 'arg' => 2 }]) }
|
230
|
+
its(:retry_attempt) { is_expected.to eq(1) }
|
231
|
+
end
|
232
|
+
|
233
|
+
context '7th attempt' do
|
234
|
+
let(:job_data) do
|
235
|
+
{
|
236
|
+
'job_class' => 'SomeJob',
|
237
|
+
'job_id' => 'uuid',
|
238
|
+
'arguments' => ['arg1', { 'arg' => 2 }],
|
239
|
+
'retry_attempt' => 7
|
240
|
+
}
|
241
|
+
end
|
242
|
+
|
243
|
+
its(:job_id) { is_expected.to eq('uuid') }
|
244
|
+
its(:arguments) { is_expected.to eq(['arg1', { 'arg' => 2 }]) }
|
245
|
+
its(:retry_attempt) { is_expected.to eq(7) }
|
246
|
+
end
|
247
|
+
end
|
154
248
|
end
|
155
249
|
|
156
250
|
describe '#rescue_with_handler' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Seymour
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|