sidekiq 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

data/Changes.md CHANGED
@@ -1,3 +1,13 @@
1
+ 2.0.3
2
+ -----------
3
+ - Fix sidekiq-web's navbar on mobile devices and windows <= 980px (ezkl)
4
+ - Fix Capistrano task for first deploys [#259]
5
+ - Worker subclasses now properly inherit sidekiq\_options set in
6
+ their superclass [#221]
7
+ - Add random jitter to scheduler to spread polls across POLL\_INTERVAL
8
+ window. [#247]
9
+ - Add note in README about new mailing list: sidekiq@librelist.org
10
+
1
11
  2.0.2
2
12
  -----------
3
13
 
data/README.md CHANGED
@@ -47,6 +47,10 @@ Please see the [sidekiq wiki](https://github.com/mperham/sidekiq/wiki) for more
47
47
  [#sidekiq on irc.freenode.net](irc://irc.freenode.net/#sidekiq) is dedicated to this project,
48
48
  but bug reports or feature requests suggestions should still go through [issues on Github](https://github.com/mperham/sidekiq/issues).
49
49
 
50
+ There's also a mailing list via [Librelist](http://librelist.org) that you can subscribe to by sending
51
+ and email to <sidekiq@librelist.org> with a greeting in the body. To unsubscribe, send an email to <sidekiq-unsubscribe@librelist.org> and that's it!
52
+ Once archiving begins, you'll be able to visit [the archives](http://librelist.com/browser/sidekiq/) to see past threads.
53
+
50
54
 
51
55
  License
52
56
  -----------------
@@ -7,7 +7,7 @@ require 'sidekiq/util'
7
7
 
8
8
  require 'sidekiq/extensions/action_mailer'
9
9
  require 'sidekiq/extensions/active_record'
10
- require 'sidekiq/rails' if defined?(::Rails)
10
+ require 'sidekiq/rails' if defined?(::Rails::Engine)
11
11
 
12
12
  require 'multi_json'
13
13
 
@@ -11,12 +11,12 @@ Capistrano::Configuration.instance.load do
11
11
 
12
12
  desc "Quiet sidekiq (stop accepting new work)"
13
13
  task :quiet, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
14
- run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
14
+ run "if [ -d #{current_path} ] && [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
15
15
  end
16
16
 
17
17
  desc "Stop sidekiq"
18
18
  task :stop, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
19
- run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
19
+ run "if [ -d #{current_path} ] && [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
20
20
  end
21
21
 
22
22
  desc "Start sidekiq"
@@ -22,6 +22,8 @@ trap 'TTIN' do
22
22
  end
23
23
  end
24
24
 
25
+ $stdout.sync = true
26
+
25
27
  require 'yaml'
26
28
  require 'singleton'
27
29
  require 'optparse'
@@ -69,7 +71,7 @@ module Sidekiq
69
71
  begin
70
72
  logger.info 'Starting processing, hit Ctrl-C to stop'
71
73
  @manager.start!
72
- poller.poll!
74
+ poller.poll!(true)
73
75
  sleep
74
76
  rescue Interrupt
75
77
  logger.info 'Shutting down'
@@ -0,0 +1,54 @@
1
+ begin
2
+ require 'active_support/core_ext/class/attribute'
3
+ rescue LoadError
4
+
5
+ # A dumbed down version of ActiveSupport's
6
+ # Class#class_attribute helper.
7
+ class Class
8
+ def class_attribute(*attrs)
9
+ instance_reader = true
10
+ instance_writer = true
11
+
12
+ attrs.each do |name|
13
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
14
+ def self.#{name}() nil end
15
+ def self.#{name}?() !!#{name} end
16
+
17
+ def self.#{name}=(val)
18
+ singleton_class.class_eval do
19
+ define_method(:#{name}) { val }
20
+ end
21
+
22
+ if singleton_class?
23
+ class_eval do
24
+ def #{name}
25
+ defined?(@#{name}) ? @#{name} : singleton_class.#{name}
26
+ end
27
+ end
28
+ end
29
+ val
30
+ end
31
+
32
+ if instance_reader
33
+ def #{name}
34
+ defined?(@#{name}) ? @#{name} : self.class.#{name}
35
+ end
36
+
37
+ def #{name}?
38
+ !!#{name}
39
+ end
40
+ end
41
+ RUBY
42
+
43
+ attr_writer name if instance_writer
44
+ end
45
+ end
46
+
47
+ private
48
+ def singleton_class?
49
+ ancestors.first != self
50
+ end
51
+ end
52
+ end
53
+
54
+
@@ -18,8 +18,10 @@ module Sidekiq
18
18
 
19
19
  SETS = %w(retry schedule)
20
20
 
21
- def poll
21
+ def poll(first_time=false)
22
22
  watchdog('scheduling poller thread died!') do
23
+ add_jitter if first_time
24
+
23
25
  # A message's "score" in Redis is the time at which it should be processed.
24
26
  # Just check Redis for the set of messages with a timestamp before now.
25
27
  now = Time.now.to_f.to_s
@@ -42,6 +44,17 @@ module Sidekiq
42
44
  end
43
45
  end
44
46
 
47
+ private
48
+
49
+ def add_jitter
50
+ begin
51
+ sleep(POLL_INTERVAL * rand)
52
+ rescue Celluloid::Task::TerminatedError
53
+ # Hit Ctrl-C when Sidekiq is finished booting and we have a chance
54
+ # to get here.
55
+ end
56
+ end
57
+
45
58
  end
46
59
  end
47
60
  end
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
@@ -179,7 +179,7 @@ module Sidekiq
179
179
  s = score.to_f
180
180
  process_score('schedule', s, :delete)
181
181
  end
182
- redirect root_path
182
+ redirect "#{root_path}scheduled"
183
183
  end
184
184
 
185
185
  post '/retries' do
@@ -192,7 +192,7 @@ module Sidekiq
192
192
  process_score('retry', s, :delete)
193
193
  end
194
194
  end
195
- redirect root_path
195
+ redirect "#{root_path}retries"
196
196
  end
197
197
 
198
198
  post "/retries/:score" do
@@ -203,7 +203,7 @@ module Sidekiq
203
203
  elsif params['delete']
204
204
  process_score('retry', score, :delete)
205
205
  end
206
- redirect root_path
206
+ redirect "#{root_path}retries"
207
207
  end
208
208
 
209
209
  def process_score(set, score, operation)
@@ -1,4 +1,5 @@
1
1
  require 'sidekiq/client'
2
+ require 'sidekiq/core_ext'
2
3
 
3
4
  module Sidekiq
4
5
 
@@ -22,6 +23,7 @@ module Sidekiq
22
23
  module Worker
23
24
  def self.included(base)
24
25
  base.extend(ClassMethods)
26
+ base.class_attribute :sidekiq_options_hash
25
27
  end
26
28
 
27
29
  def logger
@@ -51,11 +53,13 @@ module Sidekiq
51
53
  # :backtrace - whether to save any error backtrace in the retry payload to display in web UI,
52
54
  # can be true, false or an integer number of lines to save, default *false*
53
55
  def sidekiq_options(opts={})
54
- @sidekiq_options = get_sidekiq_options.merge(stringify_keys(opts || {}))
56
+ self.sidekiq_options_hash = get_sidekiq_options.merge(stringify_keys(opts || {}))
55
57
  end
56
58
 
59
+ DEFAULT_OPTIONS = { 'unique' => true, 'retry' => true, 'queue' => 'default' }
60
+
57
61
  def get_sidekiq_options # :nodoc:
58
- defined?(@sidekiq_options) ? @sidekiq_options : { 'unique' => true, 'retry' => true, 'queue' => 'default' }
62
+ self.sidekiq_options_hash ||= DEFAULT_OPTIONS
59
63
  end
60
64
 
61
65
  def stringify_keys(hash) # :nodoc:
@@ -6,6 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["mperham@gmail.com"]
7
7
  gem.description = gem.summary = "Simple, efficient message processing for Ruby"
8
8
  gem.homepage = "http://mperham.github.com/sidekiq"
9
+ gem.license = "LGPL-3.0"
9
10
 
10
11
  gem.executables = ['sidekiq', 'sidekiqctl']
11
12
  gem.files = `git ls-files`.split("\n")
@@ -73,6 +73,10 @@ class TestClient < MiniTest::Unit::TestCase
73
73
  include Sidekiq::Worker
74
74
  end
75
75
 
76
+ it 'has default options' do
77
+ assert_equal Sidekiq::Worker::ClassMethods::DEFAULT_OPTIONS, MyWorker.get_sidekiq_options
78
+ end
79
+
76
80
  it 'handles perform_async' do
77
81
  @redis.expect :rpush, 1, ['queue:default', String]
78
82
  pushed = MyWorker.perform_async(1, 2)
@@ -116,4 +120,22 @@ class TestClient < MiniTest::Unit::TestCase
116
120
  assert_equal ['bob'], Sidekiq::Client.registered_workers
117
121
  end
118
122
  end
123
+
124
+ class BaseWorker
125
+ include Sidekiq::Worker
126
+ sidekiq_options 'retry' => 'base'
127
+ end
128
+ class AWorker < BaseWorker
129
+ end
130
+ class BWorker < BaseWorker
131
+ sidekiq_options 'retry' => 'b'
132
+ end
133
+
134
+ describe 'inheritance' do
135
+ it 'should inherit sidekiq options' do
136
+ assert_equal 'base', AWorker.get_sidekiq_options['retry']
137
+ assert_equal 'b', BWorker.get_sidekiq_options['retry']
138
+ end
139
+ end
140
+
119
141
  end
@@ -81,6 +81,17 @@ class TestWeb < MiniTest::Unit::TestCase
81
81
  assert_match /HardWorker/, last_response.body
82
82
  end
83
83
 
84
+ it 'can delete scheduled' do
85
+ msg,score = add_scheduled
86
+ Sidekiq.redis do |conn|
87
+ assert_equal 1, conn.zcard('schedule')
88
+ post '/scheduled', 'score' => [score], 'delete' => 'Delete'
89
+ assert_equal 302, last_response.status
90
+ assert_equal 'http://example.org/scheduled', last_response.header['Location']
91
+ assert_equal 0, conn.zcard('schedule')
92
+ end
93
+ end
94
+
84
95
  it 'can display retries' do
85
96
  get '/retries'
86
97
  assert_equal 200, last_response.status
@@ -110,7 +121,7 @@ class TestWeb < MiniTest::Unit::TestCase
110
121
 
111
122
  post "/retries/#{score}", 'delete' => 'Delete'
112
123
  assert_equal 302, last_response.status
113
- assert_equal 'http://example.org/', last_response.header['Location']
124
+ assert_equal 'http://example.org/retries', last_response.header['Location']
114
125
 
115
126
  get "/retries"
116
127
  assert_equal 200, last_response.status
@@ -122,7 +133,7 @@ class TestWeb < MiniTest::Unit::TestCase
122
133
 
123
134
  post "/retries/#{score}", 'retry' => 'Retry'
124
135
  assert_equal 302, last_response.status
125
- assert_equal 'http://example.org/', last_response.header['Location']
136
+ assert_equal 'http://example.org/retries', last_response.header['Location']
126
137
 
127
138
  get '/queues/default'
128
139
  assert_equal 200, last_response.status
@@ -1,27 +1,6 @@
1
1
  /*
2
2
  *= require vendor/bootstrap
3
+ *= require layout
3
4
  *= require vendor/bootstrap-responsive
4
5
  *= require_self
5
6
  */
6
- body {
7
- position: relative;
8
- padding-top: 90px;
9
- }
10
-
11
- td form {
12
- margin: 0;
13
- }
14
-
15
- td form .btn {
16
- margin: 0;
17
- }
18
-
19
- code {
20
- padding: 0;
21
- border: 0;
22
- background-color: inherit;
23
- }
24
-
25
- .hero-unit {
26
- padding: 30px;
27
- }
@@ -0,0 +1,22 @@
1
+ body {
2
+ position: relative;
3
+ padding-top: 90px;
4
+ }
5
+
6
+ td form {
7
+ margin: 0;
8
+ }
9
+
10
+ td form .btn {
11
+ margin: 0;
12
+ }
13
+
14
+ code {
15
+ padding: 0;
16
+ border: 0;
17
+ background-color: inherit;
18
+ }
19
+
20
+ .hero-unit {
21
+ padding: 30px;
22
+ }
@@ -7,22 +7,27 @@ html
7
7
  .navbar.navbar-fixed-top
8
8
  .navbar-inner
9
9
  .container
10
+ a.btn.btn-navbar data-toggle="collapse" data-target=".nav-collapse"
11
+ span.icon-bar
12
+ span.icon-bar
13
+ span.icon-bar
10
14
  a.brand href='#{{root_path}}'
11
15
  | Sidekiq
12
- ul.nav
13
- li
14
- a href='#{{root_path}}' Home
15
- li
16
- a href='#{{root_path}}queues' Queues
17
- li
18
- a href='#{{root_path}}retries' Retries
19
- li
20
- a href='#{{root_path}}scheduled' Scheduled
21
- ul.nav.pull-right
22
- li
23
- a Redis: #{location}
24
- li
25
- a #{Time.now.utc}
16
+ div.nav-collapse
17
+ ul.nav
18
+ li
19
+ a href='#{{root_path}}' Home
20
+ li
21
+ a href='#{{root_path}}queues' Queues
22
+ li
23
+ a href='#{{root_path}}retries' Retries
24
+ li
25
+ a href='#{{root_path}}scheduled' Scheduled
26
+ ul.nav.pull-right
27
+ li
28
+ a Redis: #{location}
29
+ li
30
+ a #{Time.now.utc}
26
31
 
27
32
  .container
28
33
  == yield
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-13 00:00:00.000000000 Z
12
+ date: 2012-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70093698877540 !ruby/object:Gem::Requirement
16
+ requirement: &70268588228240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70093698877540
24
+ version_requirements: *70268588228240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis-namespace
27
- requirement: &70093698876900 !ruby/object:Gem::Requirement
27
+ requirement: &70268588227780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70093698876900
35
+ version_requirements: *70268588227780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: connection_pool
38
- requirement: &70093698876280 !ruby/object:Gem::Requirement
38
+ requirement: &70268588227180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70093698876280
46
+ version_requirements: *70268588227180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: celluloid
49
- requirement: &70093698875780 !ruby/object:Gem::Requirement
49
+ requirement: &70268588226500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.11.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70093698875780
57
+ version_requirements: *70268588226500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70093698891660 !ruby/object:Gem::Requirement
60
+ requirement: &70268588225840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70093698891660
68
+ version_requirements: *70268588225840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
- requirement: &70093698891180 !ruby/object:Gem::Requirement
71
+ requirement: &70268588225120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '3'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70093698891180
79
+ version_requirements: *70268588225120
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sinatra
82
- requirement: &70093698890800 !ruby/object:Gem::Requirement
82
+ requirement: &70268588224740 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70093698890800
90
+ version_requirements: *70268588224740
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: slim
93
- requirement: &70093698890340 !ruby/object:Gem::Requirement
93
+ requirement: &70268588224280 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70093698890340
101
+ version_requirements: *70268588224280
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rake
104
- requirement: &70093698889860 !ruby/object:Gem::Requirement
104
+ requirement: &70268588223740 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70093698889860
112
+ version_requirements: *70268588223740
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: actionmailer
115
- requirement: &70093698889320 !ruby/object:Gem::Requirement
115
+ requirement: &70268588223240 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '3'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70093698889320
123
+ version_requirements: *70268588223240
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: activerecord
126
- requirement: &70093698888640 !ruby/object:Gem::Requirement
126
+ requirement: &70268588222720 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '3'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70093698888640
134
+ version_requirements: *70268588222720
135
135
  description: Simple, efficient message processing for Ruby
136
136
  email:
137
137
  - mperham@gmail.com
@@ -169,6 +169,7 @@ files:
169
169
  - lib/sidekiq/capistrano.rb
170
170
  - lib/sidekiq/cli.rb
171
171
  - lib/sidekiq/client.rb
172
+ - lib/sidekiq/core_ext.rb
172
173
  - lib/sidekiq/extensions/action_mailer.rb
173
174
  - lib/sidekiq/extensions/active_record.rb
174
175
  - lib/sidekiq/extensions/generic_proxy.rb
@@ -269,6 +270,7 @@ files:
269
270
  - web/assets/javascripts/vendor/jquery.js
270
271
  - web/assets/javascripts/vendor/jquery.timeago.js
271
272
  - web/assets/stylesheets/application.css
273
+ - web/assets/stylesheets/layout.css
272
274
  - web/assets/stylesheets/vendor/bootstrap-responsive.css
273
275
  - web/assets/stylesheets/vendor/bootstrap.css
274
276
  - web/views/index.slim
@@ -279,7 +281,8 @@ files:
279
281
  - web/views/retry.slim
280
282
  - web/views/scheduled.slim
281
283
  homepage: http://mperham.github.com/sidekiq
282
- licenses: []
284
+ licenses:
285
+ - LGPL-3.0
283
286
  post_install_message:
284
287
  rdoc_options: []
285
288
  require_paths: