sidekiq-status 2.0.1 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Appraisals +4 -0
- data/CHANGELOG.md +15 -0
- data/gemfiles/sidekiq_6.1.gemfile +7 -0
- data/lib/sidekiq-status/client_middleware.rb +4 -2
- data/lib/sidekiq-status/storage.rb +4 -4
- data/lib/sidekiq-status/version.rb +1 -1
- data/spec/lib/sidekiq-status/client_middleware_spec.rb +3 -3
- data/spec/lib/sidekiq-status/server_middleware_spec.rb +4 -4
- data/spec/lib/sidekiq-status/web_spec.rb +1 -1
- data/spec/lib/sidekiq-status_spec.rb +1 -1
- data/spec/support/test_jobs.rb +3 -3
- data/web/views/status.erb +9 -8
- data/web/views/status_not_found.erb +3 -2
- data/web/views/statuses.erb +12 -11
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73189e5075131660e13e76ce8e8eeedd84953c90998941dd73a16825dc96d951
|
4
|
+
data.tar.gz: 5923bc75138cee22d8b5edcc5fbb9ad42dad4e0d89f29df74df68656a73adadc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09e500e508e3a0d309e5d817a0fb7e1f58b9013f32284608ae5e2512bd556d07e7846c240789a2df4d5790f0aa183b3623181fd14acb12fd14a863ae354f627e'
|
7
|
+
data.tar.gz: 37b1eb9dec966fc8d8645c0ea4139d9a4cee715aca5c5b988881d63599d77e4d7cc564472a3f72e58923b8fb903ed0254c123821dafa2122c622e0dfc5b1e3ca
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
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
|
|
@@ -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:
|
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 =
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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)
|
data/spec/support/test_jobs.rb
CHANGED
@@ -119,13 +119,13 @@ end
|
|
119
119
|
|
120
120
|
class RetriedJob < StubJob
|
121
121
|
|
122
|
-
sidekiq_options
|
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
|
-
|
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
|
-
|
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
|
4
|
+
<div role="alert">
|
4
5
|
<strong>Uh oh!</strong> That job can't be found. It may have expired already.
|
5
6
|
</div>
|
data/web/views/statuses.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;
|
@@ -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
|
80
|
+
<table class="table table-hover table-bordered table-striped">
|
80
81
|
<tr>
|
81
|
-
<% @headers.each do |
|
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.
|
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:
|
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.
|
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
|