sidekiq 4.2.4 → 5.2.0
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/.github/issue_template.md +8 -1
- data/.gitignore +1 -0
- data/.travis.yml +5 -3
- data/5.0-Upgrade.md +56 -0
- data/COMM-LICENSE +1 -1
- data/Changes.md +151 -0
- data/Ent-Changes.md +77 -2
- data/Gemfile +10 -25
- data/LICENSE +1 -1
- data/Pro-4.0-Upgrade.md +35 -0
- data/Pro-Changes.md +156 -2
- data/README.md +9 -6
- data/Rakefile +1 -2
- data/bin/sidekiqctl +1 -1
- data/bin/sidekiqload +15 -33
- data/lib/generators/sidekiq/templates/worker_spec.rb.erb +1 -1
- data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
- data/lib/sidekiq/api.rb +157 -67
- data/lib/sidekiq/cli.rb +71 -26
- data/lib/sidekiq/client.rb +25 -18
- data/lib/sidekiq/core_ext.rb +1 -106
- data/lib/sidekiq/delay.rb +42 -0
- data/lib/sidekiq/exception_handler.rb +2 -4
- data/lib/sidekiq/extensions/generic_proxy.rb +7 -1
- data/lib/sidekiq/fetch.rb +1 -1
- data/lib/sidekiq/job_logger.rb +25 -0
- data/lib/sidekiq/job_retry.rb +241 -0
- data/lib/sidekiq/launcher.rb +45 -37
- data/lib/sidekiq/logging.rb +18 -2
- data/lib/sidekiq/manager.rb +3 -4
- data/lib/sidekiq/middleware/server/active_record.rb +10 -0
- data/lib/sidekiq/processor.rb +91 -34
- data/lib/sidekiq/rails.rb +15 -51
- data/lib/sidekiq/redis_connection.rb +31 -5
- data/lib/sidekiq/scheduled.rb +35 -8
- data/lib/sidekiq/testing.rb +24 -7
- data/lib/sidekiq/util.rb +6 -2
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/action.rb +2 -6
- data/lib/sidekiq/web/application.rb +28 -21
- data/lib/sidekiq/web/helpers.rb +67 -23
- data/lib/sidekiq/web/router.rb +14 -10
- data/lib/sidekiq/web.rb +4 -4
- data/lib/sidekiq/worker.rb +97 -14
- data/lib/sidekiq.rb +23 -24
- data/sidekiq.gemspec +7 -10
- data/web/assets/javascripts/application.js +0 -0
- data/web/assets/javascripts/dashboard.js +18 -13
- data/web/assets/stylesheets/application-rtl.css +246 -0
- data/web/assets/stylesheets/application.css +336 -4
- data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
- data/web/assets/stylesheets/bootstrap.css +2 -2
- data/web/locales/ar.yml +80 -0
- data/web/locales/en.yml +1 -0
- data/web/locales/es.yml +4 -3
- data/web/locales/fa.yml +80 -0
- data/web/locales/he.yml +79 -0
- data/web/locales/ja.yml +5 -3
- data/web/locales/ur.yml +80 -0
- data/web/views/_footer.erb +5 -2
- data/web/views/_job_info.erb +1 -1
- data/web/views/_nav.erb +1 -1
- data/web/views/_paging.erb +1 -1
- data/web/views/busy.erb +9 -5
- data/web/views/dashboard.erb +3 -3
- data/web/views/layout.erb +11 -2
- data/web/views/morgue.erb +14 -10
- data/web/views/queue.erb +10 -10
- data/web/views/queues.erb +4 -2
- data/web/views/retries.erb +13 -11
- data/web/views/retry.erb +1 -1
- data/web/views/scheduled.erb +2 -2
- metadata +26 -160
- data/lib/sidekiq/middleware/server/logging.rb +0 -40
- data/lib/sidekiq/middleware/server/retry_jobs.rb +0 -205
- data/test/config.yml +0 -9
- data/test/env_based_config.yml +0 -11
- data/test/fake_env.rb +0 -1
- data/test/fixtures/en.yml +0 -2
- data/test/helper.rb +0 -75
- data/test/test_actors.rb +0 -138
- data/test/test_api.rb +0 -528
- data/test/test_cli.rb +0 -418
- data/test/test_client.rb +0 -266
- data/test/test_exception_handler.rb +0 -56
- data/test/test_extensions.rb +0 -127
- data/test/test_fetch.rb +0 -50
- data/test/test_launcher.rb +0 -95
- data/test/test_logging.rb +0 -35
- data/test/test_manager.rb +0 -50
- data/test/test_middleware.rb +0 -158
- data/test/test_processor.rb +0 -235
- data/test/test_rails.rb +0 -22
- data/test/test_redis_connection.rb +0 -132
- data/test/test_retry.rb +0 -326
- data/test/test_retry_exhausted.rb +0 -149
- data/test/test_scheduled.rb +0 -115
- data/test/test_scheduling.rb +0 -58
- data/test/test_sidekiq.rb +0 -107
- data/test/test_testing.rb +0 -143
- data/test/test_testing_fake.rb +0 -357
- data/test/test_testing_inline.rb +0 -94
- data/test/test_util.rb +0 -13
- data/test/test_web.rb +0 -726
- data/test/test_web_helpers.rb +0 -54
data/lib/sidekiq/web.rb
CHANGED
@@ -19,10 +19,10 @@ require 'rack/session/cookie'
|
|
19
19
|
module Sidekiq
|
20
20
|
class Web
|
21
21
|
ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../web")
|
22
|
-
VIEWS = "#{ROOT}/views"
|
23
|
-
LOCALES = ["#{ROOT}/locales"
|
24
|
-
LAYOUT = "#{VIEWS}/layout.erb"
|
25
|
-
ASSETS = "#{ROOT}/assets"
|
22
|
+
VIEWS = "#{ROOT}/views"
|
23
|
+
LOCALES = ["#{ROOT}/locales"]
|
24
|
+
LAYOUT = "#{VIEWS}/layout.erb"
|
25
|
+
ASSETS = "#{ROOT}/assets"
|
26
26
|
|
27
27
|
DEFAULT_TABS = {
|
28
28
|
"Dashboard" => '',
|
data/lib/sidekiq/worker.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'sidekiq/client'
|
3
|
-
require 'sidekiq/core_ext'
|
4
3
|
|
5
4
|
module Sidekiq
|
6
5
|
|
@@ -28,15 +27,44 @@ module Sidekiq
|
|
28
27
|
raise ArgumentError, "You cannot include Sidekiq::Worker in an ActiveJob: #{base.name}" if base.ancestors.any? {|c| c.name == 'ActiveJob::Base' }
|
29
28
|
|
30
29
|
base.extend(ClassMethods)
|
31
|
-
base.
|
32
|
-
base.
|
33
|
-
base.
|
30
|
+
base.sidekiq_class_attribute :sidekiq_options_hash
|
31
|
+
base.sidekiq_class_attribute :sidekiq_retry_in_block
|
32
|
+
base.sidekiq_class_attribute :sidekiq_retries_exhausted_block
|
34
33
|
end
|
35
34
|
|
36
35
|
def logger
|
37
36
|
Sidekiq.logger
|
38
37
|
end
|
39
38
|
|
39
|
+
# This helper class encapsulates the set options for `set`, e.g.
|
40
|
+
#
|
41
|
+
# SomeWorker.set(queue: 'foo').perform_async(....)
|
42
|
+
#
|
43
|
+
class Setter
|
44
|
+
def initialize(klass, opts)
|
45
|
+
@klass = klass
|
46
|
+
@opts = opts
|
47
|
+
end
|
48
|
+
|
49
|
+
def perform_async(*args)
|
50
|
+
@klass.client_push(@opts.merge('args' => args, 'class' => @klass))
|
51
|
+
end
|
52
|
+
|
53
|
+
# +interval+ must be a timestamp, numeric or something that acts
|
54
|
+
# numeric (like an activesupport time interval).
|
55
|
+
def perform_in(interval, *args)
|
56
|
+
int = interval.to_f
|
57
|
+
now = Time.now.to_f
|
58
|
+
ts = (int < 1_000_000_000 ? now + int : int)
|
59
|
+
|
60
|
+
payload = @opts.merge('class' => @klass, 'args' => args, 'at' => ts)
|
61
|
+
# Optimization to enqueue something now that is scheduled to go out now or in the past
|
62
|
+
payload.delete('at') if ts <= now
|
63
|
+
@klass.client_push(payload)
|
64
|
+
end
|
65
|
+
alias_method :perform_at, :perform_in
|
66
|
+
end
|
67
|
+
|
40
68
|
module ClassMethods
|
41
69
|
|
42
70
|
def delay(*args)
|
@@ -52,8 +80,7 @@ module Sidekiq
|
|
52
80
|
end
|
53
81
|
|
54
82
|
def set(options)
|
55
|
-
|
56
|
-
self
|
83
|
+
Setter.new(self, options)
|
57
84
|
end
|
58
85
|
|
59
86
|
def perform_async(*args)
|
@@ -70,7 +97,7 @@ module Sidekiq
|
|
70
97
|
item = { 'class' => self, 'args' => args, 'at' => ts }
|
71
98
|
|
72
99
|
# Optimization to enqueue something now that is scheduled to go out now or in the past
|
73
|
-
item.delete('at'
|
100
|
+
item.delete('at') if ts <= now
|
74
101
|
|
75
102
|
client_push(item)
|
76
103
|
end
|
@@ -90,7 +117,8 @@ module Sidekiq
|
|
90
117
|
# In practice, any option is allowed. This is the main mechanism to configure the
|
91
118
|
# options for a specific job.
|
92
119
|
def sidekiq_options(opts={})
|
93
|
-
|
120
|
+
# stringify
|
121
|
+
self.sidekiq_options_hash = get_sidekiq_options.merge(Hash[opts.map{|k, v| [k.to_s, v]}])
|
94
122
|
end
|
95
123
|
|
96
124
|
def sidekiq_retry_in(&block)
|
@@ -107,13 +135,68 @@ module Sidekiq
|
|
107
135
|
|
108
136
|
def client_push(item) # :nodoc:
|
109
137
|
pool = Thread.current[:sidekiq_via_pool] || get_sidekiq_options['pool'] || Sidekiq.redis_pool
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
138
|
+
# stringify
|
139
|
+
item.keys.each do |key|
|
140
|
+
item[key.to_s] = item.delete(key)
|
141
|
+
end
|
142
|
+
|
143
|
+
Sidekiq::Client.new(pool).push(item)
|
144
|
+
end
|
145
|
+
|
146
|
+
def sidekiq_class_attribute(*attrs)
|
147
|
+
instance_reader = true
|
148
|
+
instance_writer = true
|
149
|
+
|
150
|
+
attrs.each do |name|
|
151
|
+
singleton_class.instance_eval do
|
152
|
+
undef_method(name) if method_defined?(name) || private_method_defined?(name)
|
153
|
+
end
|
154
|
+
define_singleton_method(name) { nil }
|
155
|
+
|
156
|
+
ivar = "@#{name}"
|
157
|
+
|
158
|
+
singleton_class.instance_eval do
|
159
|
+
m = "#{name}="
|
160
|
+
undef_method(m) if method_defined?(m) || private_method_defined?(m)
|
161
|
+
end
|
162
|
+
define_singleton_method("#{name}=") do |val|
|
163
|
+
singleton_class.class_eval do
|
164
|
+
undef_method(name) if method_defined?(name) || private_method_defined?(name)
|
165
|
+
define_method(name) { val }
|
166
|
+
end
|
167
|
+
|
168
|
+
if singleton_class?
|
169
|
+
class_eval do
|
170
|
+
undef_method(name) if method_defined?(name) || private_method_defined?(name)
|
171
|
+
define_method(name) do
|
172
|
+
if instance_variable_defined? ivar
|
173
|
+
instance_variable_get ivar
|
174
|
+
else
|
175
|
+
singleton_class.send name
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
val
|
181
|
+
end
|
182
|
+
|
183
|
+
if instance_reader
|
184
|
+
undef_method(name) if method_defined?(name) || private_method_defined?(name)
|
185
|
+
define_method(name) do
|
186
|
+
if instance_variable_defined?(ivar)
|
187
|
+
instance_variable_get ivar
|
188
|
+
else
|
189
|
+
self.class.public_send name
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
if instance_writer
|
195
|
+
m = "#{name}="
|
196
|
+
undef_method(m) if method_defined?(m) || private_method_defined?(m)
|
197
|
+
attr_writer name
|
198
|
+
end
|
115
199
|
end
|
116
|
-
Sidekiq::Client.new(pool).push(hash)
|
117
200
|
end
|
118
201
|
|
119
202
|
end
|
data/lib/sidekiq.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
2
|
require 'sidekiq/version'
|
4
|
-
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.
|
3
|
+
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.2.2." if RUBY_PLATFORM != 'java' && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
|
5
4
|
|
6
5
|
require 'sidekiq/logging'
|
7
6
|
require 'sidekiq/client'
|
8
7
|
require 'sidekiq/worker'
|
9
8
|
require 'sidekiq/redis_connection'
|
9
|
+
require 'sidekiq/delay'
|
10
10
|
|
11
11
|
require 'json'
|
12
12
|
|
@@ -17,13 +17,14 @@ module Sidekiq
|
|
17
17
|
DEFAULTS = {
|
18
18
|
queues: [],
|
19
19
|
labels: [],
|
20
|
-
concurrency:
|
20
|
+
concurrency: 10,
|
21
21
|
require: '.',
|
22
22
|
environment: nil,
|
23
23
|
timeout: 8,
|
24
24
|
poll_interval_average: nil,
|
25
|
-
average_scheduled_poll_interval:
|
25
|
+
average_scheduled_poll_interval: 5,
|
26
26
|
error_handlers: [],
|
27
|
+
death_handlers: [],
|
27
28
|
lifecycle_events: {
|
28
29
|
startup: [],
|
29
30
|
quiet: [],
|
@@ -46,7 +47,7 @@ module Sidekiq
|
|
46
47
|
"connected_clients" => "9999",
|
47
48
|
"used_memory_human" => "9P",
|
48
49
|
"used_memory_peak_human" => "9P"
|
49
|
-
}
|
50
|
+
}
|
50
51
|
|
51
52
|
def self.❨╯°□°❩╯︵┻━┻
|
52
53
|
puts "Calm down, yo."
|
@@ -144,32 +145,34 @@ module Sidekiq
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def self.default_server_middleware
|
147
|
-
|
148
|
-
require 'sidekiq/middleware/server/logging'
|
149
|
-
|
150
|
-
Middleware::Chain.new do |m|
|
151
|
-
m.add Middleware::Server::Logging
|
152
|
-
m.add Middleware::Server::RetryJobs
|
153
|
-
end
|
148
|
+
Middleware::Chain.new
|
154
149
|
end
|
155
150
|
|
156
151
|
def self.default_worker_options=(hash)
|
157
|
-
|
152
|
+
# stringify
|
153
|
+
@default_worker_options = default_worker_options.merge(Hash[hash.map{|k, v| [k.to_s, v]}])
|
158
154
|
end
|
159
155
|
def self.default_worker_options
|
160
156
|
defined?(@default_worker_options) ? @default_worker_options : DEFAULT_WORKER_OPTIONS
|
161
157
|
end
|
162
158
|
|
159
|
+
def self.default_retries_exhausted=(prok)
|
160
|
+
logger.info { "default_retries_exhausted is deprecated, please use `config.death_handlers << -> {|job, ex| }`" }
|
161
|
+
return nil unless prok
|
162
|
+
death_handlers << prok
|
163
|
+
end
|
164
|
+
|
165
|
+
##
|
166
|
+
# Death handlers are called when all retries for a job have been exhausted and
|
167
|
+
# the job dies. It's the notification to your application
|
168
|
+
# that this job will not succeed without manual intervention.
|
169
|
+
#
|
163
170
|
# Sidekiq.configure_server do |config|
|
164
|
-
# config.
|
171
|
+
# config.death_handlers << ->(job, ex) do
|
165
172
|
# end
|
166
173
|
# end
|
167
|
-
def self.
|
168
|
-
|
169
|
-
end
|
170
|
-
@default_retries_exhausted = ->(job, ex) { }
|
171
|
-
def self.default_retries_exhausted
|
172
|
-
@default_retries_exhausted
|
174
|
+
def self.death_handlers
|
175
|
+
options[:death_handlers]
|
173
176
|
end
|
174
177
|
|
175
178
|
def self.load_json(string)
|
@@ -227,10 +230,6 @@ module Sidekiq
|
|
227
230
|
# otherwise Ruby's Thread#kill will commit. See #377.
|
228
231
|
# DO NOT RESCUE THIS ERROR IN YOUR WORKERS
|
229
232
|
class Shutdown < Interrupt; end
|
230
|
-
|
231
233
|
end
|
232
234
|
|
233
|
-
require 'sidekiq/extensions/class_methods'
|
234
|
-
require 'sidekiq/extensions/action_mailer'
|
235
|
-
require 'sidekiq/extensions/active_record'
|
236
235
|
require 'sidekiq/rails' if defined?(::Rails::Engine)
|
data/sidekiq.gemspec
CHANGED
@@ -10,17 +10,14 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.license = "LGPL-3.0"
|
11
11
|
|
12
12
|
gem.executables = ['sidekiq', 'sidekiqctl']
|
13
|
-
gem.files = `git ls-files | grep -Ev '^(myapp|examples)'`.split("\n")
|
14
|
-
gem.test_files =
|
13
|
+
gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
|
14
|
+
gem.test_files = []
|
15
15
|
gem.name = "sidekiq"
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = Sidekiq::VERSION
|
18
|
-
gem.
|
19
|
-
|
20
|
-
gem.add_dependency
|
21
|
-
gem.add_dependency
|
22
|
-
gem.
|
23
|
-
gem.add_development_dependency 'minitest', '~> 5.7', '>= 5.7.0'
|
24
|
-
gem.add_development_dependency 'rake', '~> 10.0'
|
25
|
-
gem.add_development_dependency 'rails', '>= 3.2.0'
|
18
|
+
gem.required_ruby_version = ">= 2.2.2"
|
19
|
+
|
20
|
+
gem.add_dependency 'redis', '>= 3.3.5', '< 5'
|
21
|
+
gem.add_dependency 'connection_pool', '~> 2.2', '>= 2.2.2'
|
22
|
+
gem.add_dependency 'rack-protection', '>= 1.5.0'
|
26
23
|
end
|
File without changes
|