sidekiq_status 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  # - jruby-19mode # JRuby in 1.9 mode
6
7
  # - rbx-19mode
7
8
  env:
@@ -9,11 +10,10 @@ env:
9
10
  - SHOW_SIDEKIQ=true
10
11
  matrix:
11
12
  - SIDEKIQ_VERSION="~>2.4.0"
12
- - SIDEKIQ_VERSION="~>2.5.4"
13
13
  - SIDEKIQ_VERSION="~>2.6.5"
14
- - SIDEKIQ_VERSION="~>2.7.5"
15
14
  - SIDEKIQ_VERSION="~>2.8.0"
16
- - SIDEKIQ_VERSION="~>2.9.0"
17
15
  - SIDEKIQ_VERSION="~>2.10.0"
18
- - SIDEKIQ_VERSION="~>2.11.0"
16
+ - SIDEKIQ_VERSION="~>2.12.0"
17
+ - SIDEKIQ_VERSION="~>2.13.0"
18
+ - SIDEKIQ_VERSION="~>2.14.0"
19
19
  script: bundle exec rake
data/Gemfile CHANGED
@@ -4,4 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'sidekiq', ENV['SIDEKIQ_VERSION'] if ENV['SIDEKIQ_VERSION']
7
+ gem 'activesupport', '< 4.0.0' if RUBY_VERSION < '1.9.3'
8
+ gem 'coveralls', require: false
7
9
 
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # SidekiqStatus
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/cryo28/sidekiq_status.png)](http://travis-ci.org/cryo28/sidekiq_status)
3
+ [![Build Status](https://travis-ci.org/cryo28/sidekiq_status.png?branch=master)](https://travis-ci.org/cryo28/sidekiq_status)
4
4
  [![Dependency Status](https://gemnasium.com/cryo28/sidekiq_status.png)](https://gemnasium.com/cryo28/sidekiq_status)
5
+ [![Test coverage](https://coveralls.io/repos/cryo28/sidekiq_status/badge.png?branch=master)](https://coveralls.io/r/cryo28/sidekiq_status)
5
6
 
6
7
  Sidekiq extension to track job execution statuses and returning job results back to the client in a convenient manner
7
8
 
@@ -146,13 +147,26 @@ and clean status containers.
146
147
 
147
148
  ## Changelog
148
149
 
150
+ ### 1.0.5
151
+
152
+ * Sidekiq 2.14 support
153
+ * Do not create (and display in sidekiq_status/web) status containers
154
+ for the jobs scheduled to run in the future
155
+ by the means of perform_at/perform_in (mhfs)
156
+ * Sidekiq web templates converted from .slim to .erb
157
+ * Allow specifying worker name as a String (gumayunov)
158
+ * Added ruby 2.0 to travis build matrix
159
+ * Don't be too smart in extending Sinatra template search path (springbok)
160
+ * Show worker names and adjust sidekiq-web template tags to conform
161
+ to Sidekiq conventions (mhfs)
162
+
149
163
  ### 1.0.4
150
164
 
151
165
  * Sidekiq 2.10 and 2.11 support
152
166
 
153
167
  ### 1.0.3
154
168
 
155
- * Include SidekiqStatus::Web app into Sidekiq::Web app unobtrusively (Peter Fern)
169
+ * Include SidekiqStatus::Web app into Sidekiq::Web app unobtrusively (pdf)
156
170
  * sidekiq 2.8.0 and 2.9.0 support
157
171
 
158
172
  ### 1.0.2
@@ -172,8 +186,7 @@ and clean status containers.
172
186
  ## Roadmap
173
187
 
174
188
  * Add some sidekiq-web specs
175
-
176
-
189
+ * Support running inline with sidekiq/testing
177
190
 
178
191
  ## Contributing
179
192
 
@@ -3,8 +3,24 @@
3
3
  module SidekiqStatus
4
4
  class ClientMiddleware
5
5
  def call(worker, item, queue)
6
+ worker = worker.constantize if worker.is_a?(String)
6
7
  return yield unless worker < SidekiqStatus::Worker
7
8
 
9
+ # Don't start reporting status if the job is scheduled for the future
10
+ # When perform_at/perform_in is called this middleware is invoked within the client process
11
+ # and job arguments have 'at' parameter. If all middlewares pass the job
12
+ # Sidekiq::Client#raw_push puts the job into 'schedule' sorted set.
13
+ #
14
+ # Later, Sidekiq server ruby process periodically polls this sorted sets and repushes all
15
+ # scheduled jobs which are due to run. This repush invokes all client middlewares, but within
16
+ # sidekiq server ruby process.
17
+ #
18
+ # Luckily for us, when job is repushed, it doesn't have 'at' argument.
19
+ # So we can distinguish the condition of the middleware invokation: we don't create SidekiqStatus::Container
20
+ # when job is scheduled to run in the future, but we create status container when previously scheduled
21
+ # job is due to run.
22
+ return yield if item['at']
23
+
8
24
  jid = item['jid']
9
25
  args = item['args']
10
26
  item['args'] = [jid]
@@ -22,4 +38,4 @@ module SidekiqStatus
22
38
  raise exc
23
39
  end
24
40
  end
25
- end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module SidekiqStatus
3
3
  # SidekiqStatus version
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.5"
5
5
  end
@@ -7,11 +7,9 @@ module SidekiqStatus
7
7
  # @param [Sidekiq::Web] app
8
8
  def self.registered(app)
9
9
  app.helpers do
10
- # Calls the given block for every possible template file in views,
11
- # named name.ext, where ext is registered on engine.
12
- def find_template(views, name, engine, &block)
13
- super(VIEW_PATH, name, engine, &block)
14
- super
10
+ def sidekiq_status_template(name)
11
+ path = File.join(VIEW_PATH, name.to_s) + ".erb"
12
+ File.open(path).read
15
13
  end
16
14
  end
17
15
 
@@ -26,12 +24,12 @@ module SidekiqStatus
26
24
  pageidx = @current_page - 1
27
25
  @statuses = SidekiqStatus::Container.statuses(pageidx * @count, (pageidx + 1) * @count)
28
26
 
29
- render(:slim, :statuses)
27
+ erb(sidekiq_status_template(:statuses))
30
28
  end
31
29
 
32
30
  app.get '/statuses/:jid' do
33
31
  @status = SidekiqStatus::Container.load(params[:jid])
34
- render(:slim, :status)
32
+ erb(sidekiq_status_template(:status))
35
33
  end
36
34
 
37
35
  app.get '/statuses/:jid/kill' do
@@ -15,7 +15,7 @@ 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", ">= 2.4", "<= 2.12")
18
+ gem.add_runtime_dependency("sidekiq", ">= 2.4", "< 2.15")
19
19
 
20
20
  gem.add_development_dependency("activesupport")
21
21
  gem.add_development_dependency("rspec")
@@ -0,0 +1,29 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe SidekiqStatus::ClientMiddleware do
5
+ describe "cryo28/sidekiq_status#11 regression" do
6
+ describe "#call" do
7
+ before do
8
+ SidekiqStatus::Container.should_receive(:create).with(hash_including('worker' => 'TestWorker1'))
9
+ end
10
+
11
+ it "accepts a worker class" do
12
+ subject.call(TestWorker1, {}, nil) do
13
+ end
14
+ end
15
+
16
+ it "accepts a worker name string" do
17
+ subject.call("TestWorker1", {}, nil) do
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ it "does not create container for scheduled job" do
24
+ SidekiqStatus::Container.should_not_receive(:create)
25
+
26
+ subject.call("TestWorker1", { "at" => Time.now }, nil) do
27
+ end
28
+ end
29
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,9 @@ SimpleCov.start do
10
10
  root GEM_ROOT
11
11
  end
12
12
 
13
+ require 'coveralls'
14
+ Coveralls.wear!
15
+
13
16
  require 'sidekiq_status'
14
17
  require 'sidekiq/util'
15
18
 
data/spec/worker_spec.rb CHANGED
@@ -133,7 +133,8 @@ describe Sidekiq::Worker do
133
133
 
134
134
  worker_thread = Thread.new{ worker.perform(jid) }
135
135
  checker_thread = Thread.new do
136
- wait{ container.reload.working? }
136
+ wait{ container.reload.working? && container.at == 50 }
137
+
137
138
  container.at.should == 50
138
139
  container.total.should == 200
139
140
  container.message.should == '25% done'
@@ -0,0 +1,65 @@
1
+ <h3 class="wi">
2
+ Job <%= @status.jid %> is <%= @status.status %> (<%= @status.pct_complete %>% done)
3
+ </h3>
4
+ <p class="intro"></p>
5
+
6
+ <div id="status_<%= @status.jid %>" rel="<%= @status.status %>">
7
+ <h4>Details</h4>
8
+ <div>
9
+ <table class="table table-striped table-bordered">
10
+ <thead>
11
+ <tr>
12
+ <th>Attribute</th>
13
+ <th>Value</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <tr>
18
+ <td>jid</td>
19
+ <td><%= @status.jid %></td>
20
+ </tr>
21
+ <tr>
22
+ <td>worker</td>
23
+ <td><%= @status.worker %></td>
24
+ </tr>
25
+ <tr>
26
+ <td>status</td>
27
+ <td><%= @status.status %></td>
28
+ </tr>
29
+ <tr>
30
+ <td>last updated at</td>
31
+ <td><%= @status.last_updated_at %></td>
32
+ </tr>
33
+ <tr>
34
+ <td>at</td>
35
+ <td><%= @status.at %></td>
36
+ </tr>
37
+ <tr>
38
+ <td>total</td>
39
+ <td><%= @status.total %></td>
40
+ </tr>
41
+ <tr>
42
+ <td>message</td>
43
+ <td><%= @status.message %></td>
44
+ </tr>
45
+ <tr>
46
+ <td>payload</td>
47
+ <td>
48
+ <code class="prettyprint" language="javascript">
49
+ <%= @status.payload.to_json %>
50
+ </code>
51
+ </td>
52
+ </tr>
53
+ <tr>
54
+ <td>job args</td>
55
+ <td>
56
+ <code class="prettyprint" language="javascript">
57
+ <%= @status.args.to_json %>
58
+ </code>
59
+ </td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+ <a href="<%= to(:statuses) %>">Back</a>
64
+ </div>
65
+ </div>
@@ -0,0 +1,63 @@
1
+ <h3 class="wi">Recent job statuses</h3>
2
+
3
+ <div class="delete_jobs">
4
+ Delete jobs in&nbsp;
5
+ <a href="<%= to(:statuses) %>/delete/complete" onclick="return confirm('Are you sure? Delete is irreversible')">
6
+ complete
7
+ </a>
8
+ ,&nbsp;
9
+ <a href="<%= to(:statuses) %>/delete/finished" onclick="return confirm('Are you sure? Delete is irreversible')" title="<%= SidekiqStatus::Container::FINISHED_STATUS_NAMES.join(', ') %>">
10
+ finished
11
+ </a>
12
+ ,&nbsp;
13
+ <a href="<%= to(:statuses) %>/delete/all" onclick="return confirm('Are you sure? Delete is irreversible')">
14
+ all
15
+ </a>
16
+ &nbsp;statuses
17
+ </div>
18
+
19
+ <table class="table table-striped table-bordered">
20
+ <tr>
21
+ <th>Worker/jid</th>
22
+ <th>Status</th>
23
+ <th>Last Updated ↆ</th>
24
+ <th>Progress</th>
25
+ <th>Message</th>
26
+ <th>Actions</th>
27
+ </tr>
28
+ <% @statuses.each do |container| -%>
29
+ <tr>
30
+ <td>
31
+ <a href="<%= to(:statuses) %>/<%= container.jid %>">
32
+ <%= container.worker %>
33
+ <br />
34
+ <%= container.jid %>
35
+ </a>
36
+ </td>
37
+ <td><%= container.status %></td>
38
+ <td><%= container.last_updated_at %></td>
39
+ <td>
40
+ <div class="progress progress-striped" style="margin-bottom: 0">
41
+ <div class="bar" style="width: <%= container.pct_complete %>%; text-shadow: 1px 1px 1px black">
42
+ <%= container.pct_complete %>%
43
+ </div>
44
+ </div>
45
+ <td><%= container.message %></td>
46
+ <td>
47
+ <% if container.killable? -%>
48
+ <a class="kill" href="<%= to(:statuses) %>/<%= container.jid %>/kill" onclick="return confirm('Are you sure?')">Kill</a>
49
+ <% elsif container.kill_requested? -%>
50
+ Kill requested
51
+ <% end %>
52
+ </td>
53
+ </tr>
54
+ <% end -%>
55
+ <% if @statuses.empty? -%>
56
+ <tr>
57
+ <td colspan="6"></td>
58
+ </tr>
59
+ <% end -%>
60
+ </table>
61
+
62
+
63
+ <%= erb :_paging, :locals => { :url => "#{root_path}statuses" } %>
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
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-28 00:00:00.000000000 Z
12
+ date: 2013-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -19,9 +19,9 @@ dependencies:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '2.4'
22
- - - <=
22
+ - - <
23
23
  - !ruby/object:Gem::Version
24
- version: '2.12'
24
+ version: '2.15'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,9 +30,9 @@ dependencies:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.4'
33
- - - <=
33
+ - - <
34
34
  - !ruby/object:Gem::Version
35
- version: '2.12'
35
+ version: '2.15'
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
38
  requirement: !ruby/object:Gem::Requirement
@@ -169,6 +169,7 @@ files:
169
169
  - lib/sidekiq_status/worker.rb
170
170
  - log/.gitkeep
171
171
  - sidekiq_status.gemspec
172
+ - spec/client_middleware_spec.rb
172
173
  - spec/container_spec.rb
173
174
  - spec/dummy/app/workers/test_worker1.rb
174
175
  - spec/dummy/app/workers/test_worker2.rb
@@ -176,8 +177,8 @@ files:
176
177
  - spec/integration/sidekiq_spec.rb
177
178
  - spec/spec_helper.rb
178
179
  - spec/worker_spec.rb
179
- - web/views/status.slim
180
- - web/views/statuses.slim
180
+ - web/views/status.erb
181
+ - web/views/statuses.erb
181
182
  homepage: https://github.com/cryo28/sidekiq_status
182
183
  licenses: []
183
184
  post_install_message:
@@ -204,6 +205,7 @@ specification_version: 3
204
205
  summary: A Sidekiq extension to track job execution statuses and return job results
205
206
  back to the client in a convenient manner
206
207
  test_files:
208
+ - spec/client_middleware_spec.rb
207
209
  - spec/container_spec.rb
208
210
  - spec/dummy/app/workers/test_worker1.rb
209
211
  - spec/dummy/app/workers/test_worker2.rb
@@ -1,44 +0,0 @@
1
- h1.wi
2
- | Job #{@status.jid} is #{@status.status} (#{@status.pct_complete}% done)
3
- p.intro
4
-
5
- div id="status_#{@status.jid}" rel="#{@status.status}"
6
- h2 Details
7
- div
8
- table class="table table-striped table-bordered"
9
- thead
10
- tr
11
- th Attribute
12
- th Value
13
- tbody
14
- tr
15
- td jid
16
- td= @status.jid
17
- tr
18
- td status
19
- td= @status.status
20
- tr
21
- td last updated at
22
- td= @status.last_updated_at
23
- tr
24
- td at
25
- td= @status.at
26
- tr
27
- td total
28
- td= @status.total
29
- tr
30
- td message
31
- td= @status.message
32
- tr
33
- td payload
34
- td
35
- code class="prettyprint language-javascript"
36
- = @status.payload.to_json
37
- tr
38
- td job args
39
- td
40
- code class="prettyprint language-javascript"
41
- = @status.args.to_json
42
-
43
- a href=(to(:statuses)) Back
44
-
@@ -1,41 +0,0 @@
1
- h1.wi Recent job statuses
2
-
3
- div.delete_jobs
4
- | Delete jobs in&nbsp;
5
- a href="#{to(:statuses)}/delete/complete" onclick="return confirm('Are you sure? Delete is irreversible')" = "complete"
6
- |,&nbsp;
7
- a href="#{to(:statuses)}/delete/finished" onclick="return confirm('Are you sure? Delete is irreversible')" title="#{SidekiqStatus::Container::FINISHED_STATUS_NAMES.join(', ')}" = "finished"
8
- |,&nbsp;
9
- a href="#{to(:statuses)}/delete/all" onclick="return confirm('Are you sure? Delete is irreversible')" = "all"
10
- |&nbsp;statuses
11
-
12
- table class="table table-striped table-bordered"
13
- tr
14
- th jid
15
- th Status
16
- th Last Updated ↆ
17
- th Progress
18
- th Message
19
- th Actions
20
- - @statuses.each do |container|
21
- tr
22
- td
23
- a href="#{to(:statuses)}/#{container.jid}" = container.jid
24
- td= container.status
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
32
- td
33
- - if container.killable?
34
- a.kill href="#{to(:statuses)}/#{container.jid}/kill" onclick="return confirm('Are you sure?');" Kill
35
- - elsif container.kill_requested?
36
- |Kill requested
37
- - if @statuses.empty?
38
- tr
39
- td colspan="5"
40
-
41
- == slim :_paging, :locals => { :url => "#{root_path}statuses" }