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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6af99e65af49f5719a28a8f7a1f6b1149d9d9b03
4
- data.tar.gz: b200404a99e2c1211b17a5c799ada01f6c43223a
2
+ SHA256:
3
+ metadata.gz: ac470dbfaa9bdccc0ef97b932f5b3dd713001063c6b22617a72976564a740901
4
+ data.tar.gz: 7e0bf255bce4f090a9238892185486aec556949ffb629d5879758e8302e38cd0
5
5
  SHA512:
6
- metadata.gz: 5014ce48d74a1098c36ba54f1865e53d3a36dd8577c9a6998ed122b0f2067655804e8b237e6bb30e73b701745b01746669ae1fe5325e01f842af1377a96d56e8
7
- data.tar.gz: 6db554a3e954c57fa1dae71289a76e9961f6f13338e7485c271c9fc5646aa9075e9d8cbc27eb595dfccc9394e4a0d2d31af87423efa7bb79e1eb232b0dddb9ea
6
+ metadata.gz: cd389c60190a3cfd9b4b31c382ef6f564b62dba8a2bcdec201451d06c53ecad7f653e141aa663600ddd614bb68b5fb2a888ecd47b58660db2d5b381bb90ef438
7
+ data.tar.gz: c2b36634db5c27605d82c0120048f76e90c0597d0a66b1b79dbf9529250ae0b6bab06b4ea8cc145053a23046560d1bdc2e05c335bc5c9474b6adc18192a821dc
@@ -1,3 +1,6 @@
1
+ **Version 1.0.2**
2
+ + Fixes status not being set to `:failed` after retries
3
+
1
4
  **Version 1.0.1**
2
5
  + Fixes namespacing in `sidekiq-status/testing/inline`
3
6
 
@@ -57,8 +57,7 @@ module Sidekiq::Status
57
57
  rescue Exception
58
58
  status = :failed
59
59
  if msg['retry']
60
- retry_count = msg['retry_count'] || 0
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
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Status
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -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 }
@@ -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 30, *channels do |on|
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
@@ -62,6 +62,14 @@ class FailingJob < StubJob
62
62
  end
63
63
  end
64
64
 
65
+ class RetryAndFailJob < StubJob
66
+ sidekiq_options retry: 1
67
+
68
+ def perform
69
+ raise StandardError
70
+ end
71
+ end
72
+
65
73
  class FailingHardJob < StubJob
66
74
  def perform
67
75
  raise Exception
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.1
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-01-28 00:00:00.000000000 Z
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.6.8
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