sidekiq 4.2.2 → 4.2.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.
- checksums.yaml +4 -4
- data/Changes.md +14 -0
- data/Pro-Changes.md +15 -0
- data/lib/sidekiq.rb +0 -4
- data/lib/sidekiq/cli.rb +0 -1
- data/lib/sidekiq/processor.rb +1 -1
- data/lib/sidekiq/rails.rb +37 -0
- data/lib/sidekiq/util.rb +1 -1
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web.rb +58 -5
- data/lib/sidekiq/web/action.rb +1 -3
- data/lib/sidekiq/web/application.rb +5 -6
- data/lib/sidekiq/worker.rb +3 -3
- data/sidekiq.gemspec +1 -1
- data/test/test_scheduling.rb +8 -0
- data/test/test_web.rb +60 -0
- data/web/assets/javascripts/application.js +10 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5611a44077288f2a7a7c1e46d4fdf39aa05be0f
|
4
|
+
data.tar.gz: 7c406cd5d25b49faa1af246dd12a6f3e8ccc827a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec6ef8ffffbb53e2717a82fd85de7d089b2accc799905ba8a277a4a2fe8a4ba18382eef0e5a7939deb94b4070a96f785b9513c7ffecc61499f8fb79de083dd6
|
7
|
+
data.tar.gz: 2fc1f05e9c47a36e5451665b76acfda798f5787fee4bd833f65d955a434ad375cb2c7517b1ee4500e87e9854ad957fa38ec56fe606b9bf9d7802140ac9fca34d
|
data/Changes.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Sidekiq Changes
|
2
2
|
|
3
|
+
4.2.3
|
4
|
+
-----------
|
5
|
+
|
6
|
+
- Disable use of Rails 5's Reloader API in non-development modes, it has proven
|
7
|
+
to be unstable under load [#3154]
|
8
|
+
- Allow disabling of Sidekiq::Web's cookie session to handle the
|
9
|
+
case where the app provides a session already [#3180, inkstak]
|
10
|
+
```ruby
|
11
|
+
Sidekiq::Web.set :sessions, false
|
12
|
+
```
|
13
|
+
- Fix Web UI sharding support broken in 4.2.2. [#3169]
|
14
|
+
- Fix timestamps not updating during UI polling [#3193, shaneog]
|
15
|
+
- Relax rack-protection version to >= 1.5.0
|
16
|
+
|
3
17
|
4.2.2
|
4
18
|
-----------
|
5
19
|
|
data/Pro-Changes.md
CHANGED
@@ -3,6 +3,21 @@ Sidekiq Pro Changelog
|
|
3
3
|
|
4
4
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
5
5
|
|
6
|
+
3.4.0
|
7
|
+
---------
|
8
|
+
|
9
|
+
- Introducing the newest reliable fetching algorithm: `super_fetch`! This
|
10
|
+
algorithm will replace reliable\_fetch in Pro 4.0. super\_fetch is
|
11
|
+
bullet-proof across all environments, no longer requiring stable
|
12
|
+
hostnames or an index to be set per-process. [#3077]
|
13
|
+
```ruby
|
14
|
+
Sidekiq.configure_server do |config|
|
15
|
+
config.super_fetch!
|
16
|
+
end
|
17
|
+
```
|
18
|
+
Thank you to @jonhyman for code review and the Sidekiq Pro customers that
|
19
|
+
beta tested super\_fetch.
|
20
|
+
|
6
21
|
3.3.3
|
7
22
|
---------
|
8
23
|
|
data/lib/sidekiq.rb
CHANGED
@@ -150,10 +150,6 @@ module Sidekiq
|
|
150
150
|
Middleware::Chain.new do |m|
|
151
151
|
m.add Middleware::Server::Logging
|
152
152
|
m.add Middleware::Server::RetryJobs
|
153
|
-
if defined?(::ActiveRecord::Base)
|
154
|
-
require 'sidekiq/middleware/server/active_record'
|
155
|
-
m.add Sidekiq::Middleware::Server::ActiveRecord
|
156
|
-
end
|
157
153
|
end
|
158
154
|
end
|
159
155
|
|
data/lib/sidekiq/cli.rb
CHANGED
data/lib/sidekiq/processor.rb
CHANGED
@@ -143,7 +143,7 @@ module Sidekiq
|
|
143
143
|
# we didn't properly finish it.
|
144
144
|
ack = false
|
145
145
|
rescue Exception => ex
|
146
|
-
handle_exception(ex,
|
146
|
+
handle_exception(ex, { :context => "Job raised exception", :job => job, :jobstr => jobstr })
|
147
147
|
raise
|
148
148
|
ensure
|
149
149
|
work.acknowledge if ack
|
data/lib/sidekiq/rails.rb
CHANGED
@@ -32,10 +32,47 @@ module Sidekiq
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class Rails < ::Rails::Engine
|
35
|
+
# We need to setup this up before any application configuration which might
|
36
|
+
# change Sidekiq middleware.
|
37
|
+
#
|
38
|
+
# This hook happens after `Rails::Application` is inherited within
|
39
|
+
# config/application.rb and before config is touched, usually within the
|
40
|
+
# class block. Definitely before config/environments/*.rb and
|
41
|
+
# config/initializers/*.rb.
|
42
|
+
config.before_configuration do
|
43
|
+
if ::Rails::VERSION::MAJOR < 5 && defined?(::ActiveRecord)
|
44
|
+
Sidekiq.server_middleware do |chain|
|
45
|
+
require 'sidekiq/middleware/server/active_record'
|
46
|
+
chain.add Sidekiq::Middleware::Server::ActiveRecord
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
35
51
|
initializer 'sidekiq' do
|
36
52
|
Sidekiq.hook_rails!
|
37
53
|
end
|
38
54
|
|
55
|
+
# We have to add the reloader after initialize to see if cache_classes has
|
56
|
+
# been turned on.
|
57
|
+
#
|
58
|
+
# This hook happens after all initialziers are run, just before returning
|
59
|
+
# from config/environment.rb back to sidekiq/cli.rb.
|
60
|
+
config.after_initialize do
|
61
|
+
if ::Rails::VERSION::MAJOR >= 5
|
62
|
+
# The reloader also takes care of ActiveRecord but is incompatible with
|
63
|
+
# the ActiveRecord middleware so make sure it's not in the chain already.
|
64
|
+
if defined?(Sidekiq::Middleware::Server::ActiveRecord) && Sidekiq.server_middleware.exists?(Sidekiq::Middleware::Server::ActiveRecord)
|
65
|
+
raise ArgumentError, "You are using the Sidekiq ActiveRecord middleware and the new Rails 5 reloader which are incompatible. Please remove the ActiveRecord middleware from your Sidekiq middleware configuration."
|
66
|
+
elsif ::Rails.application.config.cache_classes
|
67
|
+
# The reloader API has proven to be troublesome under load in production.
|
68
|
+
# We won't use it at all when classes are cached, see #3154
|
69
|
+
Sidekiq.logger.debug { "Autoload disabled in #{::Rails.env}, Sidekiq will not reload changed classes" }
|
70
|
+
else
|
71
|
+
Sidekiq.options[:reloader] = Sidekiq::Rails::Reloader.new
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
39
76
|
class Reloader
|
40
77
|
def initialize(app = ::Rails.application)
|
41
78
|
Sidekiq.logger.debug "Enabling Rails 5+ live code reloading, so hot!" unless app.config.cache_classes
|
data/lib/sidekiq/util.rb
CHANGED
data/lib/sidekiq/version.rb
CHANGED
data/lib/sidekiq/web.rb
CHANGED
@@ -63,15 +63,30 @@ module Sidekiq
|
|
63
63
|
@views ||= VIEWS
|
64
64
|
end
|
65
65
|
|
66
|
+
def enable(*opts)
|
67
|
+
opts.each {|key| set(key, true) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def disable(*opts)
|
71
|
+
opts.each {|key| set(key, false) }
|
72
|
+
end
|
73
|
+
|
66
74
|
# Helper for the Sinatra syntax: Sidekiq::Web.set(:session_secret, Rails.application.secrets...)
|
67
75
|
def set(attribute, value)
|
68
76
|
send(:"#{attribute}=", value)
|
69
77
|
end
|
70
78
|
|
71
|
-
attr_accessor :app_url, :session_secret, :redis_pool
|
79
|
+
attr_accessor :app_url, :session_secret, :redis_pool, :sessions
|
72
80
|
attr_writer :locales, :views
|
73
81
|
end
|
74
82
|
|
83
|
+
def self.inherited(child)
|
84
|
+
child.app_url = self.app_url
|
85
|
+
child.session_secret = self.session_secret
|
86
|
+
child.redis_pool = self.redis_pool
|
87
|
+
child.sessions = self.sessions
|
88
|
+
end
|
89
|
+
|
75
90
|
def settings
|
76
91
|
self.class.settings
|
77
92
|
end
|
@@ -97,6 +112,32 @@ module Sidekiq
|
|
97
112
|
@app ||= build
|
98
113
|
end
|
99
114
|
|
115
|
+
def enable(*opts)
|
116
|
+
opts.each {|key| set(key, true) }
|
117
|
+
end
|
118
|
+
|
119
|
+
def disable(*opts)
|
120
|
+
opts.each {|key| set(key, false) }
|
121
|
+
end
|
122
|
+
|
123
|
+
def set(attribute, value)
|
124
|
+
send(:"#{attribute}=", value)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Default values
|
128
|
+
set :sessions, true
|
129
|
+
|
130
|
+
attr_writer :sessions
|
131
|
+
|
132
|
+
def sessions
|
133
|
+
unless instance_variable_defined?("@sessions")
|
134
|
+
@sessions = self.class.sessions
|
135
|
+
@sessions = @sessions.to_hash.dup if @sessions.respond_to?(:to_hash)
|
136
|
+
end
|
137
|
+
|
138
|
+
@sessions
|
139
|
+
end
|
140
|
+
|
100
141
|
def self.register(extension)
|
101
142
|
extension.registered(WebApplication)
|
102
143
|
end
|
@@ -109,22 +150,34 @@ module Sidekiq
|
|
109
150
|
end
|
110
151
|
end
|
111
152
|
|
112
|
-
def
|
153
|
+
def build_sessions
|
113
154
|
middlewares = self.middlewares
|
114
|
-
klass = self.class
|
115
155
|
|
116
156
|
unless using?(::Rack::Protection) || ENV['RACK_ENV'] == 'test'
|
117
157
|
middlewares.unshift [[::Rack::Protection, { use: :authenticity_token }], nil]
|
118
158
|
end
|
119
159
|
|
160
|
+
s = sessions
|
161
|
+
return unless s
|
162
|
+
|
120
163
|
unless using? ::Rack::Session::Cookie
|
121
164
|
unless secret = Web.session_secret
|
122
165
|
require 'securerandom'
|
123
166
|
secret = SecureRandom.hex(64)
|
124
167
|
end
|
125
168
|
|
126
|
-
|
169
|
+
options = { secret: secret }
|
170
|
+
options = options.merge(s.to_hash) if s.respond_to? :to_hash
|
171
|
+
|
172
|
+
middlewares.unshift [[::Rack::Session::Cookie, options], nil]
|
127
173
|
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def build
|
177
|
+
build_sessions
|
178
|
+
|
179
|
+
middlewares = self.middlewares
|
180
|
+
klass = self.class
|
128
181
|
|
129
182
|
::Rack::Builder.new do
|
130
183
|
%w(stylesheets javascripts images).each do |asset_dir|
|
@@ -147,7 +200,7 @@ module Sidekiq
|
|
147
200
|
end
|
148
201
|
|
149
202
|
if defined?(::ActionDispatch::Request::Session) &&
|
150
|
-
!::ActionDispatch::Request::Session.
|
203
|
+
!::ActionDispatch::Request::Session.method_defined?(:each)
|
151
204
|
# mperham/sidekiq#2460
|
152
205
|
# Rack apps can't reuse the Rails session store without
|
153
206
|
# this monkeypatch, fixed in Rails 5.
|
data/lib/sidekiq/web/action.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Sidekiq
|
4
4
|
class WebAction
|
5
5
|
RACK_SESSION = 'rack.session'.freeze
|
6
|
-
TEXT_HTML = { "Content-Type" => "text/html", "Cache-Control" => "no-cache" }.freeze
|
7
|
-
APPLICATION_JSON = { "Content-Type" => "application/json", "Cache-Control" => "no-cache" }.freeze
|
8
6
|
|
9
7
|
attr_accessor :env, :block, :type
|
10
8
|
|
@@ -70,7 +68,7 @@ module Sidekiq
|
|
70
68
|
end
|
71
69
|
|
72
70
|
def json(payload)
|
73
|
-
[200,
|
71
|
+
[200, { "Content-Type" => "application/json", "Cache-Control" => "no-cache" }, [Sidekiq.dump_json(payload)]]
|
74
72
|
end
|
75
73
|
|
76
74
|
def initialize(env, block)
|
@@ -7,7 +7,6 @@ module Sidekiq
|
|
7
7
|
CONTENT_LENGTH = "Content-Length".freeze
|
8
8
|
CONTENT_TYPE = "Content-Type".freeze
|
9
9
|
REDIS_KEYS = %w(redis_version uptime_in_days connected_clients used_memory_human used_memory_peak_human)
|
10
|
-
NOT_FOUND = [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass" }.freeze, ["Not Found"]]
|
11
10
|
|
12
11
|
def initialize(klass)
|
13
12
|
@klass = klass
|
@@ -28,7 +27,7 @@ module Sidekiq
|
|
28
27
|
def self.set(key, val)
|
29
28
|
# nothing, backwards compatibility
|
30
29
|
end
|
31
|
-
|
30
|
+
|
32
31
|
get "" do
|
33
32
|
redirect(root_path)
|
34
33
|
end
|
@@ -262,7 +261,7 @@ module Sidekiq
|
|
262
261
|
|
263
262
|
def call(env)
|
264
263
|
action = self.class.match(env)
|
265
|
-
return
|
264
|
+
return [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass" }, ["Not Found"]] unless action
|
266
265
|
|
267
266
|
resp = catch(:halt) do
|
268
267
|
app = @klass
|
@@ -284,11 +283,11 @@ module Sidekiq
|
|
284
283
|
else
|
285
284
|
type_header = case action.type
|
286
285
|
when :json
|
287
|
-
|
286
|
+
{ "Content-Type" => "application/json", "Cache-Control" => "no-cache" }
|
288
287
|
when String
|
289
|
-
{
|
288
|
+
{ "Content-Type" => action.type, "Cache-Control" => "no-cache" }
|
290
289
|
else
|
291
|
-
|
290
|
+
{ "Content-Type" => "text/html", "Cache-Control" => "no-cache" }
|
292
291
|
end
|
293
292
|
|
294
293
|
[200, type_header, [resp]]
|
data/lib/sidekiq/worker.rb
CHANGED
@@ -64,13 +64,13 @@ module Sidekiq
|
|
64
64
|
# numeric (like an activesupport time interval).
|
65
65
|
def perform_in(interval, *args)
|
66
66
|
int = interval.to_f
|
67
|
-
now = Time.now
|
68
|
-
ts = (int < 1_000_000_000 ?
|
67
|
+
now = Time.now.to_f
|
68
|
+
ts = (int < 1_000_000_000 ? now + int : int)
|
69
69
|
|
70
70
|
item = { 'class' => self, 'args' => args, 'at' => ts }
|
71
71
|
|
72
72
|
# Optimization to enqueue something now that is scheduled to go out now or in the past
|
73
|
-
item.delete('at'.freeze) if ts <= now
|
73
|
+
item.delete('at'.freeze) if ts <= now
|
74
74
|
|
75
75
|
client_push(item)
|
76
76
|
end
|
data/sidekiq.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'redis', '~> 3.2', '>= 3.2.1'
|
19
19
|
gem.add_dependency 'connection_pool', '~> 2.2', '>= 2.2.0'
|
20
20
|
gem.add_dependency 'concurrent-ruby', '~> 1.0'
|
21
|
-
gem.add_dependency 'rack-protection', '
|
21
|
+
gem.add_dependency 'rack-protection', '>= 1.5.0'
|
22
22
|
gem.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
|
23
23
|
gem.add_development_dependency 'minitest', '~> 5.7', '>= 5.7.0'
|
24
24
|
gem.add_development_dependency 'rake', '~> 10.0'
|
data/test/test_scheduling.rb
CHANGED
@@ -11,6 +11,11 @@ class TestScheduling < Sidekiq::Test
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
# Assume we can pass any class as time to perform_in
|
15
|
+
class TimeDuck
|
16
|
+
def to_f; 42.0 end
|
17
|
+
end
|
18
|
+
|
14
19
|
it 'schedules jobs' do
|
15
20
|
ss = Sidekiq::ScheduledSet.new
|
16
21
|
ss.clear
|
@@ -34,6 +39,9 @@ class TestScheduling < Sidekiq::Test
|
|
34
39
|
|
35
40
|
assert Sidekiq::Client.push_bulk('class' => ScheduledWorker, 'args' => [['mike'], ['mike']], 'at' => 600)
|
36
41
|
assert_equal 5, ss.size
|
42
|
+
|
43
|
+
assert ScheduledWorker.perform_in(TimeDuck.new, 'samwise')
|
44
|
+
assert_equal 6, ss.size
|
37
45
|
end
|
38
46
|
|
39
47
|
it 'removes the enqueued_at field when scheduling' do
|
data/test/test_web.rb
CHANGED
@@ -663,4 +663,64 @@ class TestWeb < Sidekiq::Test
|
|
663
663
|
assert_equal 'nicehost.org', session_options[:host]
|
664
664
|
end
|
665
665
|
end
|
666
|
+
|
667
|
+
describe 'sidekiq web sessions options' do
|
668
|
+
include Rack::Test::Methods
|
669
|
+
|
670
|
+
describe 'using #disable' do
|
671
|
+
def app
|
672
|
+
app = Sidekiq::Web.new
|
673
|
+
app.disable(:sessions)
|
674
|
+
app
|
675
|
+
end
|
676
|
+
|
677
|
+
it "doesn't create sessions" do
|
678
|
+
get '/'
|
679
|
+
assert_nil last_request.env['rack.session']
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
describe 'using #set with false argument' do
|
684
|
+
def app
|
685
|
+
app = Sidekiq::Web.new
|
686
|
+
app.set(:sessions, false)
|
687
|
+
app
|
688
|
+
end
|
689
|
+
|
690
|
+
it "doesn't create sessions" do
|
691
|
+
get '/'
|
692
|
+
assert_nil last_request.env['rack.session']
|
693
|
+
end
|
694
|
+
end
|
695
|
+
|
696
|
+
describe 'using #set with an hash' do
|
697
|
+
def app
|
698
|
+
app = Sidekiq::Web.new
|
699
|
+
app.set(:sessions, { domain: :all })
|
700
|
+
app
|
701
|
+
end
|
702
|
+
|
703
|
+
it "creates sessions" do
|
704
|
+
get '/'
|
705
|
+
refute_nil last_request.env['rack.session']
|
706
|
+
refute_empty last_request.env['rack.session'].options
|
707
|
+
assert_equal :all, last_request.env['rack.session'].options[:domain]
|
708
|
+
end
|
709
|
+
end
|
710
|
+
|
711
|
+
describe 'using #enable' do
|
712
|
+
def app
|
713
|
+
app = Sidekiq::Web.new
|
714
|
+
app.enable(:sessions)
|
715
|
+
app
|
716
|
+
end
|
717
|
+
|
718
|
+
it "creates sessions" do
|
719
|
+
get '/'
|
720
|
+
refute_nil last_request.env['rack.session']
|
721
|
+
refute_empty last_request.env['rack.session'].options
|
722
|
+
refute_nil last_request.env['rack.session'].options[:secret]
|
723
|
+
end
|
724
|
+
end
|
725
|
+
end
|
666
726
|
end
|
@@ -39,16 +39,20 @@ $(function() {
|
|
39
39
|
$($(this).attr('data-target')).toggle();
|
40
40
|
});
|
41
41
|
|
42
|
-
|
42
|
+
updateFuzzyTimes($('body').data('locale'));
|
43
|
+
});
|
44
|
+
|
45
|
+
function updateFuzzyTimes(locale) {
|
43
46
|
var parts = locale.split('-');
|
44
47
|
if (typeof parts[1] !== 'undefined') {
|
45
48
|
parts[1] = parts[1].toUpperCase();
|
46
49
|
locale = parts.join('_');
|
47
50
|
}
|
51
|
+
|
48
52
|
var t = timeago()
|
49
53
|
t.render(document.querySelectorAll('time'), locale);
|
50
54
|
t.cancel();
|
51
|
-
}
|
55
|
+
}
|
52
56
|
|
53
57
|
function updatePage(url) {
|
54
58
|
setInterval(function () {
|
@@ -63,10 +67,14 @@ function updatePage(url) {
|
|
63
67
|
|
64
68
|
var $header_status = $data.find('.status')
|
65
69
|
$('.status').replaceWith($header_status)
|
70
|
+
|
71
|
+
updateFuzzyTimes($('body').data('locale'));
|
66
72
|
})
|
67
73
|
}, parseInt(localStorage.timeInterval) || 2000);
|
68
74
|
}
|
69
75
|
|
76
|
+
|
77
|
+
|
70
78
|
$(function() {
|
71
79
|
'use strict';
|
72
80
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -68,16 +68,16 @@ dependencies:
|
|
68
68
|
name: rack-protection
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - "
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
73
|
+
version: 1.5.0
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 1.5.0
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: redis-namespace
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|