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.
- data/.gitignore +1 -2
- data/.rvmrc +1 -1
- data/README.md +27 -5
- data/lib/sidekiq_status/version.rb +1 -1
- data/log/.gitkeep +0 -0
- data/sidekiq_status.gemspec +2 -1
- data/spec/dummy/app/workers/test_worker1.rb +8 -0
- data/spec/dummy/app/workers/test_worker2.rb +13 -0
- data/spec/dummy/boot.rb +15 -0
- data/spec/integration/sidekiq_spec.rb +73 -0
- data/spec/spec_helper.rb +7 -7
- data/web/views/statuses.slim +7 -3
- metadata +38 -7
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use 1.9.3-
|
1
|
+
rvm use 1.9.3-p374-perf@sidekiq_status --create
|
data/README.md
CHANGED
@@ -144,16 +144,38 @@ and clean status containers.
|
|
144
144
|
1. Setup Sidekiq web interface according to Sidekiq documentation
|
145
145
|
2. Add "require 'sidekiq_status/web'" beneath "require 'sidekiq/web'"
|
146
146
|
|
147
|
+
## Changelog
|
148
|
+
|
149
|
+
### 1.0.2
|
150
|
+
|
151
|
+
* sidekiq 2.7.0 support
|
152
|
+
* sidekiq integration tests
|
153
|
+
* Display progress bar and last message in sidekiq-web tab (leandrocg)
|
154
|
+
|
155
|
+
### 1.0.1
|
156
|
+
|
157
|
+
* sidekiq 2.6.x support
|
158
|
+
|
159
|
+
### 1.0.0
|
160
|
+
|
161
|
+
* First release
|
162
|
+
|
163
|
+
## Roadmap
|
164
|
+
|
165
|
+
* Add some sidekiq-web specs
|
166
|
+
|
167
|
+
|
168
|
+
|
147
169
|
## Contributing
|
148
170
|
|
149
171
|
1. Fork it
|
150
172
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
151
|
-
3.
|
152
|
-
4.
|
153
|
-
5.
|
154
|
-
|
173
|
+
3. Don't forget to write specs. Make sure rake spec passes
|
174
|
+
4. Commit your changes (`git commit -am 'Added some feature'`)
|
175
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
176
|
+
6. Create new Pull Request
|
155
177
|
|
156
178
|
## Copyright
|
157
179
|
|
158
|
-
SidekiqStatus © 2012 by Artem Ignatyev. SidekiqStatus is licensed under the MIT license
|
180
|
+
SidekiqStatus © 2012-2013 by Artem Ignatyev. SidekiqStatus is licensed under the MIT license
|
159
181
|
|
data/log/.gitkeep
ADDED
File without changes
|
data/sidekiq_status.gemspec
CHANGED
@@ -15,8 +15,9 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = SidekiqStatus::VERSION
|
17
17
|
|
18
|
-
gem.add_runtime_dependency("sidekiq", "
|
18
|
+
gem.add_runtime_dependency("sidekiq", ">= 2.6", "<= 2.8")
|
19
19
|
|
20
|
+
gem.add_development_dependency("activesupport")
|
20
21
|
gem.add_development_dependency("rspec")
|
21
22
|
gem.add_development_dependency("simplecov")
|
22
23
|
gem.add_development_dependency("rake")
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class TestWorker2
|
2
|
+
include SidekiqStatus::Worker
|
3
|
+
|
4
|
+
def perform(redis_key)
|
5
|
+
signal = nil
|
6
|
+
while signal != 'stop'
|
7
|
+
signal = Sidekiq.redis{ |conn| conn.get(redis_key) }
|
8
|
+
i = signal.to_i
|
9
|
+
self.at(i, "Some message at #{i}")
|
10
|
+
sleep(0.1)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/dummy/boot.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
require 'active_support/dependencies'
|
6
|
+
|
7
|
+
DUMMY_APP_ROOT = Pathname.new(File.expand_path('../', __FILE__))
|
8
|
+
Sidekiq.redis = {:url => "redis://localhost/15", :size => 5}
|
9
|
+
|
10
|
+
ActiveSupport::Dependencies.autoload_paths += Dir.glob(DUMMY_APP_ROOT.join('app/*'))
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SidekiqStatus::Worker do
|
4
|
+
def run_sidekiq(show_sidekiq_output = ENV['SHOW_SIDEKIQ'])
|
5
|
+
log_to = show_sidekiq_output ? STDOUT : GEM_ROOT.join('log/spawned_sidekiq.log').to_s
|
6
|
+
command = 'bundle exec sidekiq -r ./boot.rb --concurrency 1'
|
7
|
+
|
8
|
+
Process.spawn(
|
9
|
+
command,
|
10
|
+
:chdir => DUMMY_APP_ROOT,
|
11
|
+
:err => :out,
|
12
|
+
:out => log_to
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def with_sidekiq_running
|
17
|
+
pid = run_sidekiq
|
18
|
+
|
19
|
+
begin
|
20
|
+
yield(pid)
|
21
|
+
ensure
|
22
|
+
Process.kill('USR1', pid)
|
23
|
+
Process.wait(pid, Process::WNOHANG)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def wait(&block)
|
28
|
+
Timeout.timeout(15) do
|
29
|
+
sleep(0.5) while !block.call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "integrates seamlessly with sidekiq and" do
|
34
|
+
it "allows to query for complete job status and request payload" do
|
35
|
+
some_value = 'some_value'
|
36
|
+
jid = TestWorker1.perform_async(some_value)
|
37
|
+
container = SidekiqStatus::Container.load(jid)
|
38
|
+
container.should be_waiting
|
39
|
+
|
40
|
+
with_sidekiq_running do
|
41
|
+
wait{ container.reload.complete? }
|
42
|
+
|
43
|
+
container.total.should == 200
|
44
|
+
container.payload.should == some_value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "allows to query for working job status and request payload" do
|
49
|
+
redis_key = 'SomeRedisKey'
|
50
|
+
|
51
|
+
jid = TestWorker2.perform_async(redis_key)
|
52
|
+
container = SidekiqStatus::Container.load(jid)
|
53
|
+
container.should be_waiting
|
54
|
+
|
55
|
+
with_sidekiq_running do
|
56
|
+
wait{ container.reload.working? }
|
57
|
+
|
58
|
+
Sidekiq.redis{ |conn| conn.set(redis_key, 10) }
|
59
|
+
wait{ container.reload.at == 10 }
|
60
|
+
container.message.should == 'Some message at 10'
|
61
|
+
|
62
|
+
Sidekiq.redis{ |conn| conn.set(redis_key, 50) }
|
63
|
+
wait{ container.reload.at == 50 }
|
64
|
+
container.message.should == 'Some message at 50'
|
65
|
+
|
66
|
+
Sidekiq.redis{ |conn| conn.set(redis_key, 'stop') }
|
67
|
+
wait{ container.reload.complete? }
|
68
|
+
container.should be_complete
|
69
|
+
container.message.should be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'bundler'
|
3
3
|
Bundler.setup
|
4
|
-
|
5
4
|
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
|
5
|
+
GEM_ROOT = Pathname.new(File.expand_path('../..', __FILE__))
|
6
6
|
|
7
|
-
require 'simplecov'
|
8
|
-
SimpleCov.start
|
9
7
|
|
10
|
-
|
8
|
+
require 'simplecov'
|
9
|
+
SimpleCov.start do
|
10
|
+
root GEM_ROOT
|
11
|
+
end
|
11
12
|
|
12
13
|
require 'sidekiq_status'
|
13
14
|
require 'sidekiq/util'
|
@@ -16,12 +17,11 @@ require 'timecop'
|
|
16
17
|
|
17
18
|
Sidekiq.logger.level = Logger::ERROR
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
|
21
|
+
require GEM_ROOT.join('spec/dummy/boot.rb')
|
21
22
|
|
22
23
|
RSpec.configure do |c|
|
23
24
|
c.before do
|
24
|
-
Sidekiq.redis = REDIS
|
25
25
|
Sidekiq.redis{ |conn| conn.flushdb }
|
26
26
|
end
|
27
27
|
|
data/web/views/statuses.slim
CHANGED
@@ -16,22 +16,26 @@ table class="table table-striped table-bordered"
|
|
16
16
|
th Last Updated ↆ
|
17
17
|
th Progress
|
18
18
|
th Message
|
19
|
+
th Actions
|
19
20
|
- @statuses.each do |container|
|
20
21
|
tr
|
21
22
|
td
|
22
23
|
a href="#{to(:statuses)}/#{container.jid}" = container.jid
|
23
24
|
td= container.status
|
24
25
|
td= container.last_updated_at
|
26
|
+
td
|
27
|
+
.progress.progress-striped style="margin-bottom: 0"
|
28
|
+
.bar style='width: #{container.pct_complete}%; text-shadow: 1px 1px 1px black'
|
29
|
+
= "#{container.pct_complete}%"
|
30
|
+
|
31
|
+
td= container.message
|
25
32
|
td
|
26
33
|
- if container.killable?
|
27
34
|
a.kill href="#{to(:statuses)}/#{container.jid}/kill" onclick="return confirm('Are you sure?');" Kill
|
28
35
|
- elsif container.kill_requested?
|
29
36
|
|Kill requested
|
30
|
-
td= container.message
|
31
37
|
- if @statuses.empty?
|
32
38
|
tr
|
33
39
|
td colspan="5"
|
34
40
|
|
35
41
|
== slim :_paging, :locals => { :url => "#{root_path}statuses" }
|
36
|
-
|
37
|
-
|
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.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,46 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.6'
|
22
|
+
- - <=
|
20
23
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
24
|
+
version: '2.8'
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
none: false
|
26
29
|
requirements:
|
27
|
-
- -
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.6'
|
33
|
+
- - <=
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '2.8'
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
28
42
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
30
52
|
- !ruby/object:Gem::Dependency
|
31
53
|
name: rspec
|
32
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,8 +167,13 @@ files:
|
|
145
167
|
- lib/sidekiq_status/version.rb
|
146
168
|
- lib/sidekiq_status/web.rb
|
147
169
|
- lib/sidekiq_status/worker.rb
|
170
|
+
- log/.gitkeep
|
148
171
|
- sidekiq_status.gemspec
|
149
172
|
- spec/container_spec.rb
|
173
|
+
- spec/dummy/app/workers/test_worker1.rb
|
174
|
+
- spec/dummy/app/workers/test_worker2.rb
|
175
|
+
- spec/dummy/boot.rb
|
176
|
+
- spec/integration/sidekiq_spec.rb
|
150
177
|
- spec/spec_helper.rb
|
151
178
|
- spec/worker_spec.rb
|
152
179
|
- web/views/status.slim
|
@@ -171,13 +198,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
198
|
version: '0'
|
172
199
|
requirements: []
|
173
200
|
rubyforge_project:
|
174
|
-
rubygems_version: 1.8.
|
201
|
+
rubygems_version: 1.8.25
|
175
202
|
signing_key:
|
176
203
|
specification_version: 3
|
177
204
|
summary: A Sidekiq extension to track job execution statuses and return job results
|
178
205
|
back to the client in a convenient manner
|
179
206
|
test_files:
|
180
207
|
- spec/container_spec.rb
|
208
|
+
- spec/dummy/app/workers/test_worker1.rb
|
209
|
+
- spec/dummy/app/workers/test_worker2.rb
|
210
|
+
- spec/dummy/boot.rb
|
211
|
+
- spec/integration/sidekiq_spec.rb
|
181
212
|
- spec/spec_helper.rb
|
182
213
|
- spec/worker_spec.rb
|
183
214
|
has_rdoc:
|