sidekiq-status 2.0.1 → 2.1.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: 45893560f4594985006d2842f460861137e46903197e173761ad9bcd96db5b49
4
- data.tar.gz: 5de9712752bf085f4792e4e018709e1fc9436a5f246c3c39ad4b0916df3f8df3
3
+ metadata.gz: 73189e5075131660e13e76ce8e8eeedd84953c90998941dd73a16825dc96d951
4
+ data.tar.gz: 5923bc75138cee22d8b5edcc5fbb9ad42dad4e0d89f29df74df68656a73adadc
5
5
  SHA512:
6
- metadata.gz: ee2aa4d21c57403eb01b7fe5a011301dc2a085ffd8aa7498252684f7456d480a82642381c3a9cab970c9fbe9f3275db585de492a0574a474de8604c555f63853
7
- data.tar.gz: 0bef9d092bf1c756195fcb46828ca3b85754cb597878d7d52164afb70f492a01416d45672d3de9cad7c7256afb366e1b736f7709ab1ebc5d34d85dc64f5756ff
6
+ metadata.gz: '09e500e508e3a0d309e5d817a0fb7e1f58b9013f32284608ae5e2512bd556d07e7846c240789a2df4d5790f0aa183b3623181fd14acb12fd14a863ae354f627e'
7
+ data.tar.gz: 37b1eb9dec966fc8d8645c0ea4139d9a4cee715aca5c5b988881d63599d77e4d7cc564472a3f72e58923b8fb903ed0254c123821dafa2122c622e0dfc5b1e3ca
data/.travis.yml CHANGED
@@ -6,6 +6,7 @@ rvm:
6
6
  - ruby-head
7
7
  gemfile:
8
8
  - gemfiles/sidekiq_5.x.gemfile
9
+ - gemfiles/sidekiq_6.1.gemfile
9
10
  - gemfiles/sidekiq_6.x.gemfile
10
11
  before_install:
11
12
  - gem update --system
data/Appraisals CHANGED
@@ -2,6 +2,10 @@ appraise "sidekiq-5.x" do
2
2
  gem "sidekiq", "~> 5"
3
3
  end
4
4
 
5
+ appraise "sidekiq-6.1" do
6
+ gem "sidekiq", "~> 6.1"
7
+ end
8
+
5
9
  appraise "sidekiq-6.x" do
6
10
  gem "sidekiq", "~> 6"
7
11
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ **Version 2.1.3**
2
+ * Fixes redis deprecation warnings (https://github.com/kenaniah/sidekiq-status/issues/11)
3
+
4
+ **Version 2.1.2**
5
+ * Casts values to strings when HTML-encoding
6
+
7
+ **Version 2.1.1**
8
+ * Ensures parameter outputs are properly HTML-encoded
9
+
10
+ **Version 2.1.0**
11
+ * Adds support for Sidekiq 6.2.2+ (https://github.com/mperham/sidekiq/issues/4955)
12
+
13
+ **Version 2.0.2**
14
+ * Fixes for dark mode theme
15
+
1
16
  **Version 2.0.1**
2
17
  * Adds support for dark mode to the job status page
3
18
 
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sidekiq", "~> 6.1"
6
+
7
+ gemspec path: "../"
@@ -1,4 +1,6 @@
1
1
  require 'sidekiq/api'
2
+ JOB_CLASS = Sidekiq.constants.include?(:JobRecord) ? Sidekiq::JobRecord : Sidekiq::Job
3
+
2
4
  module Sidekiq::Status
3
5
  # Should be in the client middleware chain
4
6
  class ClientMiddleware
@@ -34,7 +36,7 @@ module Sidekiq::Status
34
36
  initial_metadata = {
35
37
  jid: msg['jid'],
36
38
  status: :queued,
37
- worker: Sidekiq::Job.new(msg, queue).display_class,
39
+ worker: JOB_CLASS.new(msg, queue).display_class,
38
40
  args: display_args(msg, queue)
39
41
  }
40
42
  store_for_id msg['jid'], initial_metadata, job_class.new.expiration || @expiration, redis_pool
@@ -45,7 +47,7 @@ module Sidekiq::Status
45
47
  end
46
48
 
47
49
  def display_args(msg, queue)
48
- job = Sidekiq::Job.new(msg, queue)
50
+ job = JOB_CLASS.new(msg, queue)
49
51
  return job.display_args.to_a.empty? ? nil : job.display_args.to_json
50
52
  rescue Exception => e
51
53
  # For Sidekiq ~> 2.7
@@ -13,10 +13,10 @@ module Sidekiq::Status::Storage
13
13
  # @return [String] Redis operation status code
14
14
  def store_for_id(id, status_updates, expiration = nil, redis_pool=nil)
15
15
  redis_connection(redis_pool) do |conn|
16
- conn.multi do
17
- conn.hmset key(id), 'update_time', Time.now.to_i, *(status_updates.to_a.flatten(1))
18
- conn.expire key(id), (expiration || Sidekiq::Status::DEFAULT_EXPIRY)
19
- conn.publish "status_updates", id
16
+ conn.multi do |pipeline|
17
+ pipeline.hmset key(id), 'update_time', Time.now.to_i, *(status_updates.to_a.flatten(1))
18
+ pipeline.expire key(id), (expiration || Sidekiq::Status::DEFAULT_EXPIRY)
19
+ pipeline.publish "status_updates", id
20
20
  end[0]
21
21
  end
22
22
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Status
3
- VERSION = '2.0.1'
3
+ VERSION = '2.1.3'
4
4
  end
5
5
  end
@@ -12,13 +12,13 @@ describe Sidekiq::Status::ClientMiddleware do
12
12
  describe "without :expiration parameter" do
13
13
 
14
14
  it "sets queued status" do
15
- expect(StubJob.perform_async arg1: 'val1').to eq(job_id)
15
+ expect(StubJob.perform_async 'arg1' => 'val1').to eq(job_id)
16
16
  expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('queued')
17
17
  expect(Sidekiq::Status::queued?(job_id)).to be_truthy
18
18
  end
19
19
 
20
20
  it "sets status hash ttl" do
21
- expect(StubJob.perform_async arg1: 'val1').to eq(job_id)
21
+ expect(StubJob.perform_async 'arg1' => 'val1').to eq(job_id)
22
22
  expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl("sidekiq:status:#{job_id}")
23
23
  end
24
24
 
@@ -50,7 +50,7 @@ describe Sidekiq::Status::ClientMiddleware do
50
50
  end
51
51
 
52
52
  it "overwrites default expiry value" do
53
- StubJob.perform_async arg1: 'val1'
53
+ StubJob.perform_async 'arg1' => 'val1'
54
54
  expect((Sidekiq::Status::DEFAULT_EXPIRY+1)..huge_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
55
55
  end
56
56
 
@@ -10,7 +10,7 @@ describe Sidekiq::Status::ServerMiddleware do
10
10
  allow(SecureRandom).to receive(:hex).once.and_return(job_id)
11
11
  start_server do
12
12
  thread = redis_thread 4, "status_updates", "job_messages_#{job_id}"
13
- expect(ConfirmationJob.perform_async arg1: 'val1').to eq(job_id)
13
+ expect(ConfirmationJob.perform_async 'arg1' => 'val1').to eq(job_id)
14
14
  expect(thread.value).to eq([
15
15
  job_id,
16
16
  job_id,
@@ -90,7 +90,7 @@ describe Sidekiq::Status::ServerMiddleware do
90
90
  it "sets status hash ttl" do
91
91
  allow(SecureRandom).to receive(:hex).once.and_return(job_id)
92
92
  start_server do
93
- expect(StubJob.perform_async arg1: 'val1').to eq(job_id)
93
+ expect(StubJob.perform_async 'arg1' => 'val1').to eq(job_id)
94
94
  end
95
95
  expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl("sidekiq:status:#{job_id}")
96
96
  end
@@ -104,7 +104,7 @@ describe Sidekiq::Status::ServerMiddleware do
104
104
 
105
105
  it "overwrites default expiry value" do
106
106
  start_server(:expiration => huge_expiration) do
107
- StubJob.perform_async arg1: 'val1'
107
+ StubJob.perform_async 'arg1' => 'val1'
108
108
  end
109
109
  expect((Sidekiq::Status::DEFAULT_EXPIRY-1)..huge_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
110
110
  end
@@ -113,7 +113,7 @@ describe Sidekiq::Status::ServerMiddleware do
113
113
  overwritten_expiration = huge_expiration * 100
114
114
  allow_any_instance_of(StubJob).to receive(:expiration).and_return(overwritten_expiration)
115
115
  start_server(:expiration => huge_expiration) do
116
- StubJob.perform_async arg1: 'val1'
116
+ StubJob.perform_async 'arg1' => 'val1'
117
117
  end
118
118
  expect((huge_expiration+1)..overwritten_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
119
119
  end
@@ -61,7 +61,7 @@ describe 'sidekiq status web' do
61
61
  get "/statuses/#{job_id}"
62
62
  expect(last_response).to be_ok
63
63
  expect(last_response.body).to match(/#{job_id}/)
64
- expect(last_response.body).to match(/1,"another argument"/)
64
+ expect(last_response.body).to match(/1,"another argument"/)
65
65
  expect(last_response.body).to match(/working/)
66
66
  end
67
67
 
@@ -159,7 +159,7 @@ describe Sidekiq::Status do
159
159
  end
160
160
 
161
161
  it "retries failed jobs" do
162
- allow(SecureRandom).to receive(:hex).and_return(retried_job_id)
162
+ allow(SecureRandom).to receive(:hex).exactly(3).times.and_return(retried_job_id)
163
163
  start_server do
164
164
  expect(capture_status_updates(3) {
165
165
  expect(RetriedJob.perform_async()).to eq(retried_job_id)
@@ -119,13 +119,13 @@ end
119
119
 
120
120
  class RetriedJob < StubJob
121
121
 
122
- sidekiq_options 'retry' => true
122
+ sidekiq_options retry: true
123
123
  sidekiq_retry_in do |count| 3 end # 3 second delay > job timeout in test suite
124
124
 
125
- def perform()
125
+ def perform
126
126
  Sidekiq.redis do |conn|
127
127
  key = "RetriedJob_#{jid}"
128
- unless conn.exists key
128
+ if [0, false].include? conn.exists(key)
129
129
  conn.set key, 'tried'
130
130
  raise StandardError
131
131
  end
data/web/views/status.erb CHANGED
@@ -1,3 +1,4 @@
1
+ <% require 'cgi'; def h(v); CGI.escape_html(v.to_s); end %>
1
2
  <style>
2
3
  .progress {
3
4
  background-color: #C8E1ED;
@@ -14,9 +15,9 @@
14
15
  </style>
15
16
 
16
17
  <h3>
17
- Job Status: <%= @status["jid"] %>
18
- <span class='label label-<%= @status["label"] %>'>
19
- <%= @status["status"] %>
18
+ Job Status: <%= h @status["jid"] %>
19
+ <span class='label label-<%= h @status["label"] %>'>
20
+ <%= h @status["status"] %>
20
21
  </span>
21
22
  </h3>
22
23
 
@@ -30,14 +31,14 @@
30
31
 
31
32
  <div class="panel panel-default" style="background-color: inherit">
32
33
  <div class="panel-body">
33
- <h4><%= @status["worker"] %></h4>
34
+ <h4><%= h @status["worker"] %></h4>
34
35
 
35
36
  <div class="row">
36
37
  <div class="col-sm-2">
37
38
  <strong>Arguments</strong>
38
39
  </div>
39
40
  <div class="col-sm-10">
40
- <p><%= @status["args"].empty? ? "<i>none</i>" : @status["args"] %></p>
41
+ <p><%= @status["args"].empty? ? "<i>none</i>" : h(@status["args"]) %></p>
41
42
  </div>
42
43
  </div>
43
44
 
@@ -46,7 +47,7 @@
46
47
  <strong>Message</strong>
47
48
  </div>
48
49
  <div class="col-sm-10">
49
- <p><%= @status["message"] || "<i>none</i>" %></p>
50
+ <p><%= h(@status["message"]) || "<i>none</i>" %></p>
50
51
  </div>
51
52
  </div>
52
53
 
@@ -75,9 +76,9 @@
75
76
  </div>
76
77
  <div class="col-sm-10">
77
78
  <% if val && val.include?("\n") %>
78
- <pre><%= val %></pre>
79
+ <pre><%= h val %></pre>
79
80
  <% else %>
80
- <p><%= val || "<i>none</i>" %></p>
81
+ <p><%= h(val) || "<i>none</i>" %></p>
81
82
  <% end %>
82
83
  </div>
83
84
  </div>
@@ -1,5 +1,6 @@
1
- <h3>Job Status: <%= params[:jid] %></h3>
1
+ <% require 'cgi'; def h(v); CGI.escape_html(v.to_s); end %>
2
+ <h3>Job Status: <%= h params[:jid] %></h3>
2
3
 
3
- <div class="alert alert-danger" role="alert">
4
+ <div role="alert">
4
5
  <strong>Uh oh!</strong> That job can't be found. It may have expired already.
5
6
  </div>
@@ -1,3 +1,4 @@
1
+ <% require 'cgi'; def h(v); CGI.escape_html(v.to_s); end %>
1
2
  <style>
2
3
  .progress {
3
4
  background-color: #C8E1ED;
@@ -76,11 +77,11 @@ function setPerPage(select){
76
77
  </div>
77
78
  </div>
78
79
  </div>
79
- <table class="table table-hover table-bordered table-striped table-white">
80
+ <table class="table table-hover table-bordered table-striped">
80
81
  <tr>
81
- <% @headers.each do |h| %>
82
- <th class="header <%= h[:class] %> header_<%= h[:id] %>">
83
- <a href="<%= h[:url] %>"><%= h[:name] %></a>
82
+ <% @headers.each do |hdr| %>
83
+ <th class="header <%= h hdr[:class] %> header_<%= h hdr[:id] %>">
84
+ <a href="<%= h hdr[:url] %>"><%= h hdr[:name] %></a>
84
85
  </th>
85
86
  <% end %>
86
87
  <th class="header">
@@ -90,13 +91,13 @@ function setPerPage(select){
90
91
  <% @statuses.each do |container| %>
91
92
  <tr>
92
93
  <td>
93
- <div title='<%= container["jid"] %>'><a href="<%= root_path %>statuses/<%= container["jid"] %>"><%= container["worker"] %></a></div>
94
+ <div title='<%= h container["jid"] %>'><a href="<%= root_path %>statuses/<%= h container["jid"] %>"><%= h container["worker"] %></a></div>
94
95
  </td>
95
96
  <td>
96
- <div class='args' title='<%= container["jid"] %>'><%= container["args"] %></div>
97
+ <div class='args' title='<%= h container["jid"] %>'><%= h container["args"] %></div>
97
98
  </td>
98
99
  <td style='text-align: center;'>
99
- <div class='label label-<%= container["label"] %>'><%= container["status"] %></div>
100
+ <div class='label label-<%= h container["label"] %>'><%= h container["status"] %></div>
100
101
  </td>
101
102
  <% secs = Time.now.to_i - container["update_time"].to_i %>
102
103
  <td style='text-align: center; white-space: nowrap;' title="<%= Time.at(container["update_time"].to_i) %>">
@@ -109,11 +110,11 @@ function setPerPage(select){
109
110
  <td>
110
111
  <div class="progress progress-striped" style="margin-bottom: 0">
111
112
  <div class='message' style='text-align:right; padding-right:0.5em; background-color: transparent; float:right;'>
112
- <%= container["message"] %>
113
+ <%= h container["message"] %>
113
114
  </div>
114
115
  <% if container["pct_complete"].to_i > 0 %>
115
- <div class="bar message" style="width: <%= container["pct_complete"] %>%;">
116
- <%= container["pct_complete"] %>%
116
+ <div class="bar message" style="width: <%= h container["pct_complete"] %>%;">
117
+ <%= h container["pct_complete"] %>%
117
118
  </div>
118
119
  <% end %>
119
120
  </div>
@@ -121,7 +122,7 @@ function setPerPage(select){
121
122
  <td>
122
123
  <div class="actions">
123
124
  <form action="statuses" method="post">
124
- <input type="hidden" name="jid" value="<%= container["jid"] %>" />
125
+ <input type="hidden" name="jid" value="<%= h container["jid"] %>" />
125
126
  <%= csrf_tag %>
126
127
  <% if container["status"] == "complete" %>
127
128
  <input type="hidden" name="_method" value="delete" />
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: 2.0.1
4
+ version: 2.1.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: 2021-06-28 00:00:00.000000000 Z
12
+ date: 2022-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -142,6 +142,7 @@ files:
142
142
  - README.md
143
143
  - Rakefile
144
144
  - gemfiles/sidekiq_5.x.gemfile
145
+ - gemfiles/sidekiq_6.1.gemfile
145
146
  - gemfiles/sidekiq_6.x.gemfile
146
147
  - lib/sidekiq-status.rb
147
148
  - lib/sidekiq-status/client_middleware.rb
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  - !ruby/object:Gem::Version
187
188
  version: '0'
188
189
  requirements: []
189
- rubygems_version: 3.2.15
190
+ rubygems_version: 3.2.32
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: An extension to the sidekiq message processing to track your jobs