sidekiq-status 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 050f6bb1416f428ce6e8b38300431c76832dd89a7ce92d1f90f5edaf7fd9b5e0
4
- data.tar.gz: 5cf3a75ac599cf0b66335192deaa51a25dfe26b3495d37a3f432aa54714fd054
3
+ metadata.gz: 7c4653623b20223d993b2c5f2ce82a1ee214083c1adb51530a76d82e4d2b3977
4
+ data.tar.gz: 6cee1ff677b1b964465e79facf5dd1e747c6747f9e99c7fd54e0330082a4b201
5
5
  SHA512:
6
- metadata.gz: 28c52b02ab40a16e8e9353894742217cdec0f3852552c0d4c509cb77f444e837f38c7540a445aca5b422a7d60bafec6baae943dc5d7813f389600c67a3a18150
7
- data.tar.gz: '09672189232d2e8bf4cbfbe26cb3035284ef2086a431f29385227305ec177f9a69f1f8407e31ee006603eb240cd9ec343adc0b7df7d32e2ef35636cdf0e29a2a'
6
+ metadata.gz: 99971994088169aa3ba0c21417557ce9d9fc072917b06c05a9cb7815f0405e331882f057d56079b41256f028c8248a780d9f74592a660a850959109a579519cc
7
+ data.tar.gz: aa7030ebbbb8161f5e9e81c3fac25357cac7bff62d810a3f785e9343c12c3a5839f94060d993aafc5381700b7803ca5e1de17dcb00762525eda6fa9a6bdb4725
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ **Version 3.0.3**
2
+ - Fixes a Sidekiq warning about the deprecated `hmset` redis command (https://github.com/kenaniah/sidekiq-status/pull/37)
3
+
4
+ **Version 3.0.2**
5
+ - Avoids setting statuses for non-status jobs when an exception is thrown (https://github.com/kenaniah/sidekiq-status/pull/32)
6
+
1
7
  **Version 3.0.1**
2
8
  - Adds elapsed time and ETA to the job status page (https://github.com/kenaniah/sidekiq-status/pull/13)
3
9
 
@@ -43,26 +43,28 @@ module Sidekiq::Status
43
43
  return
44
44
  end
45
45
 
46
- # Determine job expiration
47
- expiry = job_class.new.expiration || @expiration rescue @expiration
48
-
49
- store_status worker.jid, :working, expiry
50
- yield
51
- store_status worker.jid, :complete, expiry
52
- rescue Worker::Stopped
53
- store_status worker.jid, :stopped, expiry
54
- rescue SystemExit, Interrupt
55
- store_status worker.jid, :interrupted, expiry
56
- raise
57
- rescue Exception
58
- status = :failed
59
- if msg['retry']
60
- if retry_attempt_number(msg) < retry_attempts_from(msg['retry'], DEFAULT_MAX_RETRY_ATTEMPTS)
61
- status = :retrying
46
+ begin
47
+ # Determine job expiration
48
+ expiry = job_class.new.expiration || @expiration rescue @expiration
49
+
50
+ store_status worker.jid, :working, expiry
51
+ yield
52
+ store_status worker.jid, :complete, expiry
53
+ rescue Worker::Stopped
54
+ store_status worker.jid, :stopped, expiry
55
+ rescue SystemExit, Interrupt
56
+ store_status worker.jid, :interrupted, expiry
57
+ raise
58
+ rescue Exception
59
+ status = :failed
60
+ if msg['retry']
61
+ if retry_attempt_number(msg) < retry_attempts_from(msg['retry'], DEFAULT_MAX_RETRY_ATTEMPTS)
62
+ status = :retrying
63
+ end
62
64
  end
65
+ store_status(worker.jid, status, expiry) if job_class && job_class.ancestors.include?(Sidekiq::Status::Worker)
66
+ raise
63
67
  end
64
- store_status(worker.jid, status, expiry) if job_class && job_class.ancestors.include?(Sidekiq::Status::Worker)
65
- raise
66
68
  end
67
69
 
68
70
  private
@@ -15,7 +15,7 @@ module Sidekiq::Status::Storage
15
15
  status_updates.transform_values!(&:to_s)
16
16
  redis_connection(redis_pool) do |conn|
17
17
  conn.multi do |pipeline|
18
- pipeline.hmset key(id), 'update_time', Time.now.to_i, *(status_updates.to_a.flatten(1))
18
+ pipeline.hset key(id), 'update_time', Time.now.to_i, *(status_updates.to_a.flatten(1))
19
19
  pipeline.expire key(id), (expiration || Sidekiq::Status::DEFAULT_EXPIRY)
20
20
  pipeline.publish "status_updates", id
21
21
  end[0]
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Status
3
- VERSION = '3.0.1'
3
+ VERSION = '3.0.3'
4
4
  end
5
5
  end
@@ -61,6 +61,22 @@ describe Sidekiq::Status::ServerMiddleware do
61
61
  end
62
62
  expect(redis.hget("sidekiq:status:#{job_id}", :status)).to be_nil
63
63
  end
64
+
65
+ it "should not set any status on system exit signal" do
66
+ allow(SecureRandom).to receive(:hex).once.and_return(job_id)
67
+ start_server do
68
+ expect(ExitedNoStatusJob.perform_async).to eq(job_id)
69
+ end
70
+ expect(redis.hget("sidekiq:status:#{job_id}", :status)).to be_nil
71
+ end
72
+
73
+ it "should not set any status on interrupt signal" do
74
+ allow(SecureRandom).to receive(:hex).once.and_return(job_id)
75
+ start_server do
76
+ expect(InterruptedNoStatusJob.perform_async).to eq(job_id)
77
+ end
78
+ expect(redis.hget("sidekiq:status:#{job_id}", :status)).to be_nil
79
+ end
64
80
  end
65
81
 
66
82
  context "sets interrupted status" do
@@ -111,12 +111,24 @@ class ExitedJob < StubJob
111
111
  end
112
112
  end
113
113
 
114
+ class ExitedNoStatusJob < StubNoStatusJob
115
+ def perform
116
+ raise SystemExit
117
+ end
118
+ end
119
+
114
120
  class InterruptedJob < StubJob
115
121
  def perform
116
122
  raise Interrupt
117
123
  end
118
124
  end
119
125
 
126
+ class InterruptedNoStatusJob < StubNoStatusJob
127
+ def perform
128
+ raise Interrupt
129
+ end
130
+ end
131
+
120
132
  class RetriedJob < StubJob
121
133
 
122
134
  sidekiq_options retry: true
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: 3.0.1
4
+ version: 3.0.3
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: 2023-02-18 00:00:00.000000000 Z
12
+ date: 2023-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq