sidekiq 5.2.9 → 6.0.0.pre1
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/.standard.yml +20 -0
- data/.travis.yml +5 -2
- data/6.0-Upgrade.md +58 -0
- data/Changes.md +21 -9
- data/Gemfile +12 -11
- data/Rakefile +5 -4
- data/bin/sidekiqctl +1 -10
- data/lib/generators/sidekiq/worker_generator.rb +12 -14
- data/lib/sidekiq.rb +53 -42
- data/lib/sidekiq/api.rb +132 -145
- data/lib/sidekiq/cli.rb +95 -147
- data/lib/sidekiq/client.rb +44 -45
- data/lib/sidekiq/ctl.rb +35 -109
- data/lib/sidekiq/delay.rb +5 -6
- data/lib/sidekiq/exception_handler.rb +10 -12
- data/lib/sidekiq/extensions/action_mailer.rb +10 -20
- data/lib/sidekiq/extensions/active_record.rb +9 -7
- data/lib/sidekiq/extensions/class_methods.rb +9 -7
- data/lib/sidekiq/extensions/generic_proxy.rb +4 -4
- data/lib/sidekiq/fetch.rb +5 -6
- data/lib/sidekiq/job_logger.rb +37 -7
- data/lib/sidekiq/job_retry.rb +45 -58
- data/lib/sidekiq/launcher.rb +58 -47
- data/lib/sidekiq/logger.rb +69 -0
- data/lib/sidekiq/manager.rb +6 -8
- data/lib/sidekiq/middleware/chain.rb +2 -1
- data/lib/sidekiq/middleware/i18n.rb +5 -7
- data/lib/sidekiq/paginator.rb +11 -12
- data/lib/sidekiq/processor.rb +42 -45
- data/lib/sidekiq/rails.rb +2 -26
- data/lib/sidekiq/redis_connection.rb +31 -37
- data/lib/sidekiq/scheduled.rb +17 -19
- data/lib/sidekiq/testing.rb +22 -23
- data/lib/sidekiq/testing/inline.rb +2 -1
- data/lib/sidekiq/util.rb +18 -15
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web.rb +36 -44
- data/lib/sidekiq/web/action.rb +14 -10
- data/lib/sidekiq/web/application.rb +59 -56
- data/lib/sidekiq/web/helpers.rb +66 -67
- data/lib/sidekiq/web/router.rb +17 -14
- data/lib/sidekiq/worker.rb +12 -13
- data/sidekiq.gemspec +7 -7
- metadata +15 -27
- data/lib/sidekiq/core_ext.rb +0 -1
- data/lib/sidekiq/logging.rb +0 -122
- data/lib/sidekiq/middleware/server/active_record.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66e4721768942652832cd78e2ff64152e0bfe87e43a591d10c456999988838b4
|
4
|
+
data.tar.gz: 3186e6bec7a002151d7d6fb4baf83f6072aa3823434d96dbfac8ed52c3ea9ea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97aaa9b382b95c01c42019bdc12bc80f3805bbe9fa28921c0d5bd0b1383affd5e081464c75004dd07b780cc60d865cfea03ea1585a52ce3d9f89a06b5801353
|
7
|
+
data.tar.gz: f9de3b4b488af11c085cd8c1f577e98f661e446ce0074f7da63fa36ba559892bd53e29abcb2c09215c82c866c98e8d7afeb6d42563aa516be587dfe66b37e265
|
data/.standard.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
ruby_version: 2.5.0
|
2
|
+
fix: false
|
3
|
+
parallel: true
|
4
|
+
ignore:
|
5
|
+
- test/**/*
|
6
|
+
- examples/**/*
|
7
|
+
- myapp/**/*
|
8
|
+
- 'lib/sidekiq.rb':
|
9
|
+
- Lint/InheritException
|
10
|
+
- 'lib/sidekiq/extensions/**/*':
|
11
|
+
- Style/MethodMissingSuper
|
12
|
+
- Style/MissingRespondToMissing
|
13
|
+
- 'lib/**/*':
|
14
|
+
- Naming/AsciiIdentifiers
|
15
|
+
- Lint/RescueException
|
16
|
+
- Security/YAMLLoad
|
17
|
+
- Naming/AccessorMethodName
|
18
|
+
- Naming/MethodName
|
19
|
+
- Style/GlobalVars
|
20
|
+
- Style/Alias
|
data/.travis.yml
CHANGED
data/6.0-Upgrade.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Welcome to Sidekiq 6.0!
|
2
|
+
|
3
|
+
Sidekiq 6.0 contains some breaking changes which streamline proper operation
|
4
|
+
of Sidekiq. It also drops support for EOL versions of Ruby and Rails.
|
5
|
+
|
6
|
+
## What's New
|
7
|
+
|
8
|
+
This release has major breaking changes. Read and test carefully in production.
|
9
|
+
|
10
|
+
- Logging has been redesigned to allow pluggable formatters and several
|
11
|
+
formats ship with Sidekiq:
|
12
|
+
* default - your typical output on macOS
|
13
|
+
* heroku - enabled specifically when running in Heroku
|
14
|
+
* json - a JSON format for search indexing, one hash per line
|
15
|
+
|
16
|
+
Sidekiq will enable the best formatter for the detected environment but
|
17
|
+
you can override it by configuring the log formatter explicitly. See
|
18
|
+
'sidekiq/logger' for implementation details.
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
Sidekiq.configure_server do |config|
|
22
|
+
config.log_formatter = AcmeCorp::PlainLogFormatter.new
|
23
|
+
# config.log_formatter = Sidekiq::Logger::Format::JSON.new
|
24
|
+
end
|
25
|
+
```
|
26
|
+
- **Remove the daemonization, logfile and pidfile command line arguments**.
|
27
|
+
I've [noted for years](https://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/)
|
28
|
+
how modern services should be managed with a proper init system.
|
29
|
+
Managing services manually is more error-prone, let your operating system do it for you. See the Deployment wiki page for options.
|
30
|
+
- **Validate proper usage of the `REDIS_PROVIDER` variable.**
|
31
|
+
This variable is meant to hold the name of the environment
|
32
|
+
variable which contains your Redis URL, so that you can switch Redis
|
33
|
+
providers quickly and easily with a single variable change. It is not
|
34
|
+
meant to hold the actual Redis URL itself. If you want to manually set
|
35
|
+
the Redis URL then you may set `REDIS_URL` directly. [#3969]
|
36
|
+
- **Increase default shutdown timeout from 8 seconds to 25 seconds.**
|
37
|
+
Both Heroku and ECS now use 30 second shutdown timeout
|
38
|
+
by default and we want Sidekiq to take advantage of this time. If you
|
39
|
+
have deployment scripts which depend on the old default timeout, use `-t 8` to
|
40
|
+
get the old behavior. [#3968]
|
41
|
+
* **Rails <5** is no longer supported.
|
42
|
+
* **Ruby <2.5** is no longer supported.
|
43
|
+
* **Redis <4** is no longer supported.
|
44
|
+
|
45
|
+
## Upgrade
|
46
|
+
|
47
|
+
As always, please upgrade Sidekiq **one major version at a time**.
|
48
|
+
If you are already running Sidekiq 5.x, then:
|
49
|
+
|
50
|
+
* Upgrade to the latest Sidekiq 5.x.
|
51
|
+
```ruby
|
52
|
+
gem 'sidekiq', '< 6'
|
53
|
+
```
|
54
|
+
* Fix any deprecation warnings you see.
|
55
|
+
* Upgrade to 6.x.
|
56
|
+
```ruby
|
57
|
+
gem 'sidekiq', '< 7'
|
58
|
+
```
|
data/Changes.md
CHANGED
@@ -2,17 +2,29 @@
|
|
2
2
|
|
3
3
|
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
|
4
4
|
|
5
|
-
|
5
|
+
6.0
|
6
6
|
---------
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
This release has major breaking changes. Read and test carefully in production.
|
9
|
+
|
10
|
+
- **BREAKING CHANGE** Validate proper usage of the `REDIS_PROVIDER`
|
11
|
+
variable. This variable is meant to hold the name of the environment
|
12
|
+
variable which contains your Redis URL, so that you can switch Redis
|
13
|
+
providers quickly and easily with a single variable change. It is not
|
14
|
+
meant to hold the actual Redis URL itself. If you want to manually set
|
15
|
+
the Redis URL (not recommended as it implies you have no failover),
|
16
|
+
then you may set `REDIS_URL` directly. [#3969]
|
17
|
+
- **BREAKING CHANGE** Increase default shutdown timeout from 8 seconds
|
18
|
+
to 25 seconds. Both Heroku and ECS now use 30 second shutdown timeout
|
19
|
+
by default and we want Sidekiq to take advantage of this time. If you
|
20
|
+
have deployment scripts which depend on the old default timeout, use `-t 8` to
|
21
|
+
get the old behavior. [#3968]
|
22
|
+
- **BREAKING CHANGE** Remove the daemonization, logfile and pidfile
|
23
|
+
arguments to Sidekiq. Use a proper process supervisor (e.g. systemd or
|
24
|
+
foreman) to manage Sidekiq. See the Deployment wiki page for links to
|
25
|
+
more resources.
|
26
|
+
- Integrate the StandardRB code formatter to ensure consistent code
|
27
|
+
styling. [#4114, gearnode]
|
16
28
|
|
17
29
|
5.2.7
|
18
30
|
---------
|
data/Gemfile
CHANGED
@@ -1,23 +1,24 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
5
|
+
gem "rake"
|
6
|
+
gem "redis-namespace"
|
7
|
+
gem "rails"
|
8
|
+
gem "sqlite3", platforms: :ruby
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", platforms: :jruby
|
10
10
|
|
11
11
|
group :test do
|
12
|
-
gem
|
13
|
-
gem
|
12
|
+
gem "minitest"
|
13
|
+
gem "simplecov"
|
14
14
|
end
|
15
15
|
|
16
16
|
group :development, :test do
|
17
|
-
gem
|
17
|
+
gem "pry-byebug", platforms: :mri
|
18
|
+
gem "standard"
|
18
19
|
end
|
19
20
|
|
20
21
|
group :load_test do
|
21
|
-
gem
|
22
|
-
gem
|
22
|
+
gem "hiredis"
|
23
|
+
gem "toxiproxy"
|
23
24
|
end
|
data/Rakefile
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "standard/rake"
|
3
4
|
|
4
5
|
Rake::TestTask.new(:test) do |test|
|
5
6
|
test.warning = true
|
6
|
-
test.pattern =
|
7
|
+
test.pattern = "test/**/test_*.rb"
|
7
8
|
end
|
8
9
|
|
9
|
-
task default: :test
|
10
|
+
task default: [:standard, :test]
|
data/bin/sidekiqctl
CHANGED
@@ -7,14 +7,5 @@ require 'sidekiq/ctl'
|
|
7
7
|
if ARGV[0] == 'status'
|
8
8
|
Sidekiq::Ctl::Status.new.display(ARGV[1])
|
9
9
|
else
|
10
|
-
|
11
|
-
Sidekiq::Ctl.print_usage
|
12
|
-
else
|
13
|
-
stage = ARGV[0]
|
14
|
-
pidfile = ARGV[1]
|
15
|
-
timeout = ARGV[2].to_i
|
16
|
-
timeout = Sidekiq::Ctl::DEFAULT_KILL_TIMEOUT if timeout == 0
|
17
|
-
|
18
|
-
Sidekiq::Ctl.new(stage, pidfile, timeout)
|
19
|
-
end
|
10
|
+
Sidekiq::Ctl.print_usage
|
20
11
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require "rails/generators/named_base"
|
2
2
|
|
3
3
|
module Sidekiq
|
4
4
|
module Generators # :nodoc:
|
5
5
|
class WorkerGenerator < ::Rails::Generators::NamedBase # :nodoc:
|
6
|
-
desc
|
6
|
+
desc "This generator creates a Sidekiq Worker in app/workers and a corresponding test"
|
7
7
|
|
8
|
-
check_class_collision suffix:
|
8
|
+
check_class_collision suffix: "Worker"
|
9
9
|
|
10
10
|
def self.default_generator_root
|
11
11
|
File.dirname(__FILE__)
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_worker_file
|
15
|
-
template
|
15
|
+
template "worker.rb.erb", File.join("app/workers", class_path, "#{file_name}_worker.rb")
|
16
16
|
end
|
17
17
|
|
18
18
|
def create_test_file
|
@@ -27,23 +27,21 @@ module Sidekiq
|
|
27
27
|
|
28
28
|
def create_worker_spec
|
29
29
|
template_file = File.join(
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
"spec/workers",
|
31
|
+
class_path,
|
32
|
+
"#{file_name}_worker_spec.rb"
|
33
33
|
)
|
34
|
-
template
|
34
|
+
template "worker_spec.rb.erb", template_file
|
35
35
|
end
|
36
36
|
|
37
37
|
def create_worker_test
|
38
38
|
template_file = File.join(
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
"test/workers",
|
40
|
+
class_path,
|
41
|
+
"#{file_name}_worker_test.rb"
|
42
42
|
)
|
43
|
-
template
|
43
|
+
template "worker_test.rb.erb", template_file
|
44
44
|
end
|
45
|
-
|
46
|
-
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
data/lib/sidekiq.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.
|
3
|
+
require "sidekiq/version"
|
4
|
+
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.5.0." if RUBY_PLATFORM != "java" && Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5.0")
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
6
|
+
require "sidekiq/logger"
|
7
|
+
require "sidekiq/client"
|
8
|
+
require "sidekiq/worker"
|
9
|
+
require "sidekiq/redis_connection"
|
10
|
+
require "sidekiq/delay"
|
11
11
|
|
12
|
-
require
|
12
|
+
require "json"
|
13
13
|
|
14
14
|
module Sidekiq
|
15
|
-
NAME =
|
16
|
-
LICENSE =
|
15
|
+
NAME = "Sidekiq"
|
16
|
+
LICENSE = "See LICENSE and the LGPL-3.0 for licensing details."
|
17
17
|
|
18
18
|
DEFAULTS = {
|
19
19
|
queues: [],
|
20
20
|
labels: [],
|
21
21
|
concurrency: 10,
|
22
|
-
require:
|
22
|
+
require: ".",
|
23
23
|
environment: nil,
|
24
|
-
timeout:
|
24
|
+
timeout: 25,
|
25
25
|
poll_interval_average: nil,
|
26
26
|
average_scheduled_poll_interval: 5,
|
27
27
|
error_handlers: [],
|
@@ -38,8 +38,8 @@ module Sidekiq
|
|
38
38
|
}
|
39
39
|
|
40
40
|
DEFAULT_WORKER_OPTIONS = {
|
41
|
-
|
42
|
-
|
41
|
+
"retry" => true,
|
42
|
+
"queue" => "default",
|
43
43
|
}
|
44
44
|
|
45
45
|
FAKE_INFO = {
|
@@ -47,7 +47,7 @@ module Sidekiq
|
|
47
47
|
"uptime_in_days" => "9999",
|
48
48
|
"connected_clients" => "9999",
|
49
49
|
"used_memory_human" => "9P",
|
50
|
-
"used_memory_peak_human" => "9P"
|
50
|
+
"used_memory_peak_human" => "9P",
|
51
51
|
}
|
52
52
|
|
53
53
|
def self.❨╯°□°❩╯︵┻━┻
|
@@ -96,9 +96,13 @@ module Sidekiq
|
|
96
96
|
begin
|
97
97
|
yield conn
|
98
98
|
rescue Redis::CommandError => ex
|
99
|
-
#2550 Failover can cause the server to become a replica, need
|
99
|
+
# 2550 Failover can cause the server to become a replica, need
|
100
100
|
# to disconnect and reopen the socket to get back to the primary.
|
101
|
-
|
101
|
+
if retryable && ex.message =~ /READONLY/
|
102
|
+
conn.disconnect!
|
103
|
+
retryable = false
|
104
|
+
retry
|
105
|
+
end
|
102
106
|
raise
|
103
107
|
end
|
104
108
|
end
|
@@ -106,19 +110,17 @@ module Sidekiq
|
|
106
110
|
|
107
111
|
def self.redis_info
|
108
112
|
redis do |conn|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
conn.info
|
116
|
-
end
|
117
|
-
rescue Redis::CommandError => ex
|
118
|
-
#2850 return fake version when INFO command has (probably) been renamed
|
119
|
-
raise unless ex.message =~ /unknown command/
|
120
|
-
FAKE_INFO
|
113
|
+
# admin commands can't go through redis-namespace starting
|
114
|
+
# in redis-namespace 2.0
|
115
|
+
if conn.respond_to?(:namespace)
|
116
|
+
conn.redis.info
|
117
|
+
else
|
118
|
+
conn.info
|
121
119
|
end
|
120
|
+
rescue Redis::CommandError => ex
|
121
|
+
# 2850 return fake version when INFO command has (probably) been renamed
|
122
|
+
raise unless ex.message =~ /unknown command/
|
123
|
+
FAKE_INFO
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
@@ -152,18 +154,13 @@ module Sidekiq
|
|
152
154
|
|
153
155
|
def self.default_worker_options=(hash)
|
154
156
|
# stringify
|
155
|
-
@default_worker_options = default_worker_options.merge(Hash[hash.map{|k, v| [k.to_s, v]}])
|
157
|
+
@default_worker_options = default_worker_options.merge(Hash[hash.map {|k, v| [k.to_s, v]}])
|
156
158
|
end
|
159
|
+
|
157
160
|
def self.default_worker_options
|
158
161
|
defined?(@default_worker_options) ? @default_worker_options : DEFAULT_WORKER_OPTIONS
|
159
162
|
end
|
160
163
|
|
161
|
-
def self.default_retries_exhausted=(prok)
|
162
|
-
logger.info { "default_retries_exhausted is deprecated, please use `config.death_handlers << -> {|job, ex| }`" }
|
163
|
-
return nil unless prok
|
164
|
-
death_handlers << prok
|
165
|
-
end
|
166
|
-
|
167
164
|
##
|
168
165
|
# Death handlers are called when all retries for a job have been exhausted and
|
169
166
|
# the job dies. It's the notification to your application
|
@@ -180,15 +177,29 @@ module Sidekiq
|
|
180
177
|
def self.load_json(string)
|
181
178
|
JSON.parse(string)
|
182
179
|
end
|
180
|
+
|
183
181
|
def self.dump_json(object)
|
184
182
|
JSON.generate(object)
|
185
183
|
end
|
186
184
|
|
185
|
+
def self.log_formatter
|
186
|
+
@log_formatter ||= if ENV["DYNO"]
|
187
|
+
Sidekiq::Logger::Formatters::WithoutTimestamp.new
|
188
|
+
else
|
189
|
+
Sidekiq::Logger::Formatters::Pretty.new
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def self.log_formatter=(log_formatter)
|
194
|
+
@log_formatter = log_formatter
|
195
|
+
end
|
196
|
+
|
187
197
|
def self.logger
|
188
|
-
Sidekiq::
|
198
|
+
@logger ||= Sidekiq::Logger.new(STDOUT, level: Logger::INFO)
|
189
199
|
end
|
190
|
-
|
191
|
-
|
200
|
+
|
201
|
+
def self.logger=(logger)
|
202
|
+
@logger = logger
|
192
203
|
end
|
193
204
|
|
194
205
|
# How frequently Redis should be checked by a random Sidekiq process for
|
@@ -197,7 +208,7 @@ module Sidekiq
|
|
197
208
|
#
|
198
209
|
# See sidekiq/scheduled.rb for an in-depth explanation of this value
|
199
210
|
def self.average_scheduled_poll_interval=(interval)
|
200
|
-
|
211
|
+
options[:average_scheduled_poll_interval] = interval
|
201
212
|
end
|
202
213
|
|
203
214
|
# Register a proc to handle any error which occurs within the Sidekiq process.
|
@@ -208,7 +219,7 @@ module Sidekiq
|
|
208
219
|
#
|
209
220
|
# The default error handler logs errors to Sidekiq.logger.
|
210
221
|
def self.error_handlers
|
211
|
-
|
222
|
+
options[:error_handlers]
|
212
223
|
end
|
213
224
|
|
214
225
|
# Register a block to run at a point in the Sidekiq lifecycle.
|
@@ -234,4 +245,4 @@ module Sidekiq
|
|
234
245
|
class Shutdown < Interrupt; end
|
235
246
|
end
|
236
247
|
|
237
|
-
require
|
248
|
+
require "sidekiq/rails" if defined?(::Rails::Engine)
|