sidekiq-status 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/README.md +4 -1
- data/lib/sidekiq-status/storage.rb +9 -5
- data/lib/sidekiq-status/version.rb +1 -1
- data/spec/lib/sidekiq-status/client_middleware_spec.rb +2 -2
- data/spec/lib/sidekiq-status/server_middleware_spec.rb +5 -5
- data/spec/lib/sidekiq-status/web_spec.rb +1 -1
- data/spec/lib/sidekiq-status_spec.rb +2 -2
- data/spec/support/test_jobs.rb +1 -1
- data/web/views/statuses.erb +32 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a5a67d1f198977c5c62da1f00d692ea3ccef0be
|
4
|
+
data.tar.gz: a8da13f7d2b91592d9cb79f15f65c0702979c342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0a5f452cf20f979c8ee5032287eaa94366b3cc4016eccfee976909dff2c7c6afd30eef59f02f72d34ea929371d26418505a3f7d948a30658e49e9f138fbecb
|
7
|
+
data.tar.gz: f9b9c8f88be162c4e222a4ac1a8e9bb64d96ed459065628b761b280e9a83318f68fdd660e27c9667541a7bd2788b10ae3d19f4a3619b9be53a0436ab3fc6148d
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
Version 0.5.3:Sidekiq some tweaks in web UI, separate redis namespace
|
1
2
|
Version 0.5.2:Sidekiq versions up to 3.3.* supported, jobs sorting options in web UI, more ruby versions
|
2
3
|
Version 0.5.1:dependencies versions requirements relaxed
|
3
4
|
Version 0.5.0:Sidekiq v3 support, redis pools support
|
data/README.md
CHANGED
@@ -163,7 +163,10 @@ To use `sidekiq-status` inlining, require it too in your `{test,spec}_helper.rb`
|
|
163
163
|
* Jon Moses
|
164
164
|
* Wayne Hoover
|
165
165
|
* Dylan Robinson
|
166
|
+
* Dmitry Novotochinov
|
167
|
+
* Mohammed Elalj
|
168
|
+
* Ben Sharpe
|
166
169
|
|
167
170
|
## License
|
168
171
|
MIT License , see LICENSE for more details.
|
169
|
-
© 2012 -
|
172
|
+
© 2012 - 2015 Evgeniy Tsvigun
|
@@ -14,8 +14,8 @@ module Sidekiq::Status::Storage
|
|
14
14
|
def store_for_id(id, status_updates, expiration = nil, redis_pool=nil)
|
15
15
|
redis_connection(redis_pool) do |conn|
|
16
16
|
conn.multi do
|
17
|
-
conn.hmset id, 'update_time', Time.now.to_i, *(status_updates.to_a.flatten(1))
|
18
|
-
conn.expire id, (expiration || Sidekiq::Status::DEFAULT_EXPIRY)
|
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
19
|
conn.publish "status_updates", id
|
20
20
|
end[0]
|
21
21
|
end
|
@@ -43,7 +43,7 @@ module Sidekiq::Status::Storage
|
|
43
43
|
match = scan_scheduled_jobs_for_jid jobs, job_id
|
44
44
|
unless match.nil?
|
45
45
|
conn.zrem "schedule", match
|
46
|
-
conn.del job_id
|
46
|
+
conn.del key(job_id)
|
47
47
|
return true # Done
|
48
48
|
end
|
49
49
|
scan_options[:offset] += BATCH_LIMIT
|
@@ -58,7 +58,7 @@ module Sidekiq::Status::Storage
|
|
58
58
|
# @return [String] Redis operation status code
|
59
59
|
def read_field_for_id(id, field)
|
60
60
|
Sidekiq.redis do |conn|
|
61
|
-
conn.hmget(id, field)[0]
|
61
|
+
conn.hmget(key(id), field)[0]
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -67,7 +67,7 @@ module Sidekiq::Status::Storage
|
|
67
67
|
# @return [Hash] Hash stored in redis
|
68
68
|
def read_hash_for_id(id)
|
69
69
|
Sidekiq.redis do |conn|
|
70
|
-
conn.hgetall id
|
70
|
+
conn.hgetall key(id)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -108,4 +108,8 @@ module Sidekiq::Status::Storage
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
def key(id)
|
113
|
+
"sidekiq:status:#{id}"
|
114
|
+
end
|
111
115
|
end
|
@@ -12,14 +12,14 @@ describe Sidekiq::Status::ClientMiddleware do
|
|
12
12
|
it "sets queued status" do
|
13
13
|
allow(SecureRandom).to receive(:hex).once.and_return(job_id)
|
14
14
|
expect(StubJob.perform_async(:arg1 => 'val1')).to eq(job_id)
|
15
|
-
expect(redis.hget(job_id, :status)).to eq('queued')
|
15
|
+
expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('queued')
|
16
16
|
expect(Sidekiq::Status::queued?(job_id)).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it "sets status hash ttl" do
|
20
20
|
allow(SecureRandom).to receive(:hex).once.and_return(job_id)
|
21
21
|
expect(StubJob.perform_async(:arg1 => 'val1')).to eq(job_id)
|
22
|
-
expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl(job_id)
|
22
|
+
expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl("sidekiq:status:#{job_id}")
|
23
23
|
end
|
24
24
|
|
25
25
|
context "when redis_pool passed" do
|
@@ -20,7 +20,7 @@ describe Sidekiq::Status::ServerMiddleware do
|
|
20
20
|
"while in #perform, status = working",
|
21
21
|
job_id])
|
22
22
|
end
|
23
|
-
expect(redis.hget(job_id, :status)).to eq('complete')
|
23
|
+
expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('complete')
|
24
24
|
expect(Sidekiq::Status::complete?(job_id)).to be_truthy
|
25
25
|
end
|
26
26
|
|
@@ -31,14 +31,14 @@ describe Sidekiq::Status::ServerMiddleware do
|
|
31
31
|
expect(FailingJob.perform_async).to eq(job_id)
|
32
32
|
}).to eq([job_id]*3)
|
33
33
|
end
|
34
|
-
expect(redis.hget(job_id, :status)).to eq('failed')
|
34
|
+
expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('failed')
|
35
35
|
expect(Sidekiq::Status::failed?(job_id)).to be_truthy
|
36
36
|
end
|
37
37
|
|
38
38
|
it "sets status hash ttl" do
|
39
39
|
allow(SecureRandom).to receive(:hex).once.and_return(job_id)
|
40
40
|
expect(StubJob.perform_async(:arg1 => 'val1')).to eq(job_id)
|
41
|
-
expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl(job_id)
|
41
|
+
expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl("sidekiq:status:#{job_id}")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -52,7 +52,7 @@ describe Sidekiq::Status::ServerMiddleware do
|
|
52
52
|
start_server(:expiration => huge_expiration) do
|
53
53
|
StubJob.perform_async(:arg1 => 'val1')
|
54
54
|
end
|
55
|
-
expect((Sidekiq::Status::DEFAULT_EXPIRY+1)..huge_expiration).to cover redis.ttl(job_id)
|
55
|
+
expect((Sidekiq::Status::DEFAULT_EXPIRY+1)..huge_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
|
56
56
|
end
|
57
57
|
|
58
58
|
it "can be overwritten by worker expiration method" do
|
@@ -61,7 +61,7 @@ describe Sidekiq::Status::ServerMiddleware do
|
|
61
61
|
start_server(:expiration => huge_expiration) do
|
62
62
|
StubJob.perform_async(:arg1 => 'val1')
|
63
63
|
end
|
64
|
-
expect((huge_expiration+1)..overwritten_expiration).to cover redis.ttl(job_id)
|
64
|
+
expect((huge_expiration+1)..overwritten_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -182,8 +182,8 @@ describe Sidekiq::Status do
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def expect_2_jobs_ttl_covers(range)
|
185
|
-
expect(range).to cover redis.ttl(plain_sidekiq_job_id)
|
186
|
-
expect(range).to cover redis.ttl(job_id_1)
|
185
|
+
expect(range).to cover redis.ttl("sidekiq:status:#{plain_sidekiq_job_id}")
|
186
|
+
expect(range).to cover redis.ttl("sidekiq:status:#{job_id_1}")
|
187
187
|
end
|
188
188
|
|
189
189
|
def expect_2_jobs_are_done_and_status_eq(status)
|
data/spec/support/test_jobs.rb
CHANGED
@@ -34,7 +34,7 @@ end
|
|
34
34
|
class ConfirmationJob < StubJob
|
35
35
|
def perform(*args)
|
36
36
|
Sidekiq.redis do |conn|
|
37
|
-
conn.publish "job_messages_#{jid}", "while in #perform, status = #{conn.hget jid, :status}"
|
37
|
+
conn.publish "job_messages_#{jid}", "while in #perform, status = #{conn.hget "sidekiq:status:#{jid}", :status}"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/web/views/statuses.erb
CHANGED
@@ -1,36 +1,50 @@
|
|
1
|
+
|
1
2
|
<style>
|
2
|
-
.
|
3
|
-
|
3
|
+
.progress {
|
4
|
+
background-color: #C8E1ED;
|
5
|
+
}
|
6
|
+
.bar {
|
7
|
+
background-color: #2897cb;
|
4
8
|
}
|
5
|
-
.
|
6
|
-
|
9
|
+
.message {
|
10
|
+
text-shadow: 0 0 5px white;
|
11
|
+
font-weight: bold; padding-left: 4px;
|
12
|
+
color: #333;
|
7
13
|
}
|
8
14
|
</style>
|
9
15
|
|
10
16
|
<h3 class="wi">Recent job statuses</h3>
|
17
|
+
|
18
|
+
|
11
19
|
<table class="table table-striped table-bordered">
|
12
20
|
<tr>
|
13
|
-
|
14
|
-
|
15
|
-
|
21
|
+
<th>Worker/jid</th>
|
22
|
+
<th style='text-align:center;'>Status</th>
|
23
|
+
<th style='width: 10%; text-align:center;'>Last Updated</th>
|
24
|
+
<th style='width: 50%;'>Progress</th>
|
16
25
|
</tr>
|
17
26
|
<% @statuses.each do |container| %>
|
18
27
|
<tr>
|
19
|
-
<td>
|
20
|
-
|
21
|
-
|
22
|
-
|
28
|
+
<td><span title='<%= container.jid %>'><%= container.worker %></span></td>
|
29
|
+
<td style='text-align: center;'><span class='badge'><%= container.status %></span></td>
|
30
|
+
<% secs = Time.now.to_i - container.update_time.to_i %>
|
31
|
+
<td style='text-align: center;'>
|
32
|
+
<% if secs > 0 %>
|
33
|
+
<%= secs %> sec<%= secs == 1 ? '' : 's' %> ago
|
34
|
+
<% else %>
|
35
|
+
Now
|
36
|
+
<% end %>
|
23
37
|
</td>
|
24
|
-
<td><%= container.status %></td>
|
25
|
-
<td><%= Time.at(container.update_time.to_i) %></td>
|
26
38
|
<td>
|
27
39
|
<div class="progress progress-striped" style="margin-bottom: 0">
|
28
|
-
<div class=
|
29
|
-
|
30
|
-
<%= container.pct_complete
|
31
|
-
|
40
|
+
<div class='message' style='text-align:right; padding-right:0.5em; background-color: transparent; float:right;'><%= container.message %></div>
|
41
|
+
<% if container.pct_complete.to_i > 0 %>
|
42
|
+
<div class="bar message" style="width: <%= container.pct_complete %>%; color: white; text-shadow: 0 0 0;">
|
43
|
+
<%= container.pct_complete %>%
|
44
|
+
</div>
|
45
|
+
<% end %>
|
32
46
|
</div>
|
33
|
-
|
47
|
+
</td>
|
34
48
|
</tr>
|
35
49
|
<% end %>
|
36
50
|
<% if @statuses.empty? %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Tsvigun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.4.
|
143
|
+
rubygems_version: 2.4.6
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: An extension to the sidekiq message processing to track your jobs
|