sidekiq-status 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +3 -0
- data/lib/sidekiq-status/server_middleware.rb +13 -2
- data/lib/sidekiq-status/version.rb +1 -1
- data/spec/lib/sidekiq-status_spec.rb +23 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/test_jobs.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac470dbfaa9bdccc0ef97b932f5b3dd713001063c6b22617a72976564a740901
|
4
|
+
data.tar.gz: 7e0bf255bce4f090a9238892185486aec556949ffb629d5879758e8302e38cd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd389c60190a3cfd9b4b31c382ef6f564b62dba8a2bcdec201451d06c53ecad7f653e141aa663600ddd614bb68b5fb2a888ecd47b58660db2d5b381bb90ef438
|
7
|
+
data.tar.gz: c2b36634db5c27605d82c0120048f76e90c0597d0a66b1b79dbf9529250ae0b6bab06b4ea8cc145053a23046560d1bdc2e05c335bc5c9474b6adc18192a821dc
|
data/CHANGELOG.md
CHANGED
@@ -57,8 +57,7 @@ module Sidekiq::Status
|
|
57
57
|
rescue Exception
|
58
58
|
status = :failed
|
59
59
|
if msg['retry']
|
60
|
-
|
61
|
-
if retry_count < retry_attempts_from(msg['retry'], DEFAULT_MAX_RETRY_ATTEMPTS)
|
60
|
+
if retry_attempt_number(msg) < retry_attempts_from(msg['retry'], DEFAULT_MAX_RETRY_ATTEMPTS)
|
62
61
|
status = :retrying
|
63
62
|
end
|
64
63
|
end
|
@@ -68,9 +67,21 @@ module Sidekiq::Status
|
|
68
67
|
|
69
68
|
private
|
70
69
|
|
70
|
+
def retry_attempt_number(msg)
|
71
|
+
if msg['retry_count']
|
72
|
+
msg['retry_count'] + sidekiq_version_dependent_retry_offset
|
73
|
+
else
|
74
|
+
0
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
71
78
|
def retry_attempts_from(msg_retry, default)
|
72
79
|
msg_retry.is_a?(Integer) ? msg_retry : default
|
73
80
|
end
|
81
|
+
|
82
|
+
def sidekiq_version_dependent_retry_offset
|
83
|
+
Sidekiq.major_version >= 4 ? 1 : 0
|
84
|
+
end
|
74
85
|
end
|
75
86
|
|
76
87
|
# Helper method to easily configure sidekiq-status server middleware
|
@@ -8,6 +8,7 @@ describe Sidekiq::Status do
|
|
8
8
|
let!(:unused_id) { SecureRandom.hex(12) }
|
9
9
|
let!(:plain_sidekiq_job_id) { SecureRandom.hex(12) }
|
10
10
|
let!(:retried_job_id) { SecureRandom.hex(12) }
|
11
|
+
let!(:retry_and_fail_job_id) { SecureRandom.hex(12) }
|
11
12
|
|
12
13
|
describe ".status, .working?, .complete?" do
|
13
14
|
it "gets job status by id as symbol" do
|
@@ -174,6 +175,28 @@ describe Sidekiq::Status do
|
|
174
175
|
end
|
175
176
|
end
|
176
177
|
|
178
|
+
it "marks retried jobs as failed once they do eventually fail" do
|
179
|
+
allow(SecureRandom).to receive(:hex).and_return(retry_and_fail_job_id)
|
180
|
+
start_server do
|
181
|
+
expect(
|
182
|
+
capture_status_updates(3) {
|
183
|
+
expect(RetryAndFailJob.perform_async).to eq(retry_and_fail_job_id)
|
184
|
+
}
|
185
|
+
).to eq([retry_and_fail_job_id] * 3)
|
186
|
+
|
187
|
+
expect(Sidekiq::Status.status(retry_and_fail_job_id)).to eq(:retrying)
|
188
|
+
end
|
189
|
+
|
190
|
+
# restarting and waiting for the job to fail
|
191
|
+
start_server do
|
192
|
+
expect(capture_status_updates(3) {}).to eq([retry_and_fail_job_id] * 3)
|
193
|
+
|
194
|
+
expect(Sidekiq::Status.status(retry_and_fail_job_id)).to eq(:failed)
|
195
|
+
expect(Sidekiq::Status.failed?(retry_and_fail_job_id)).to be_truthy
|
196
|
+
expect(Sidekiq::Status::retrying?(retry_and_fail_job_id)).to be_falsey
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
177
200
|
context ":expiration param" do
|
178
201
|
before { seed_secure_random_with_job_ids }
|
179
202
|
let(:expiration_param) { Sidekiq::Status::DEFAULT_EXPIRY * 100 }
|
data/spec/spec_helper.rb
CHANGED
@@ -35,7 +35,7 @@ def redis_thread messages_limit, *channels
|
|
35
35
|
messages = []
|
36
36
|
Sidekiq.redis do |conn|
|
37
37
|
puts "Subscribing to #{channels} for #{messages_limit.to_s.bold} messages".cyan if ENV['DEBUG']
|
38
|
-
conn.subscribe_with_timeout
|
38
|
+
conn.subscribe_with_timeout 60, *channels do |on|
|
39
39
|
on.subscribe do |ch, subscriptions|
|
40
40
|
puts "Subscribed to #{ch}".cyan if ENV['DEBUG']
|
41
41
|
if subscriptions == channels.size
|
data/spec/support/test_jobs.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Tsvigun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.7.3
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: An extension to the sidekiq message processing to track your jobs
|