sidekiq 5.2.9 → 6.2.1

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.

Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +232 -0
  3. data/README.md +18 -34
  4. data/bin/sidekiq +26 -2
  5. data/bin/sidekiqload +32 -24
  6. data/bin/sidekiqmon +8 -0
  7. data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
  8. data/lib/generators/sidekiq/worker_generator.rb +21 -13
  9. data/lib/sidekiq/api.rb +257 -219
  10. data/lib/sidekiq/cli.rb +144 -180
  11. data/lib/sidekiq/client.rb +64 -48
  12. data/lib/sidekiq/delay.rb +5 -6
  13. data/lib/sidekiq/exception_handler.rb +10 -12
  14. data/lib/sidekiq/extensions/action_mailer.rb +13 -22
  15. data/lib/sidekiq/extensions/active_record.rb +13 -10
  16. data/lib/sidekiq/extensions/class_methods.rb +14 -11
  17. data/lib/sidekiq/extensions/generic_proxy.rb +4 -4
  18. data/lib/sidekiq/fetch.rb +38 -31
  19. data/lib/sidekiq/job_logger.rb +45 -7
  20. data/lib/sidekiq/job_retry.rb +62 -61
  21. data/lib/sidekiq/launcher.rb +142 -52
  22. data/lib/sidekiq/logger.rb +166 -0
  23. data/lib/sidekiq/manager.rb +11 -13
  24. data/lib/sidekiq/middleware/chain.rb +15 -5
  25. data/lib/sidekiq/middleware/i18n.rb +5 -7
  26. data/lib/sidekiq/monitor.rb +133 -0
  27. data/lib/sidekiq/paginator.rb +18 -14
  28. data/lib/sidekiq/processor.rb +71 -70
  29. data/lib/sidekiq/rails.rb +29 -37
  30. data/lib/sidekiq/redis_connection.rb +50 -48
  31. data/lib/sidekiq/scheduled.rb +28 -29
  32. data/lib/sidekiq/sd_notify.rb +149 -0
  33. data/lib/sidekiq/systemd.rb +24 -0
  34. data/lib/sidekiq/testing/inline.rb +2 -1
  35. data/lib/sidekiq/testing.rb +35 -24
  36. data/lib/sidekiq/util.rb +45 -16
  37. data/lib/sidekiq/version.rb +2 -1
  38. data/lib/sidekiq/web/action.rb +15 -11
  39. data/lib/sidekiq/web/application.rb +84 -74
  40. data/lib/sidekiq/web/csrf_protection.rb +180 -0
  41. data/lib/sidekiq/web/helpers.rb +108 -79
  42. data/lib/sidekiq/web/router.rb +23 -19
  43. data/lib/sidekiq/web.rb +60 -105
  44. data/lib/sidekiq/worker.rb +126 -102
  45. data/lib/sidekiq.rb +69 -44
  46. data/sidekiq.gemspec +23 -16
  47. data/web/assets/images/apple-touch-icon.png +0 -0
  48. data/web/assets/javascripts/application.js +25 -27
  49. data/web/assets/javascripts/dashboard.js +4 -23
  50. data/web/assets/stylesheets/application-dark.css +160 -0
  51. data/web/assets/stylesheets/application.css +33 -8
  52. data/web/locales/de.yml +14 -2
  53. data/web/locales/en.yml +2 -0
  54. data/web/locales/fr.yml +3 -3
  55. data/web/locales/ja.yml +4 -1
  56. data/web/locales/lt.yml +83 -0
  57. data/web/locales/pl.yml +4 -4
  58. data/web/locales/ru.yml +4 -0
  59. data/web/locales/vi.yml +83 -0
  60. data/web/views/_job_info.erb +2 -1
  61. data/web/views/busy.erb +51 -17
  62. data/web/views/dead.erb +2 -2
  63. data/web/views/layout.erb +2 -0
  64. data/web/views/morgue.erb +5 -2
  65. data/web/views/queue.erb +11 -2
  66. data/web/views/queues.erb +9 -1
  67. data/web/views/retries.erb +5 -2
  68. data/web/views/retry.erb +2 -2
  69. data/web/views/scheduled.erb +5 -2
  70. metadata +27 -60
  71. data/.circleci/config.yml +0 -61
  72. data/.github/contributing.md +0 -32
  73. data/.github/issue_template.md +0 -11
  74. data/.gitignore +0 -15
  75. data/.travis.yml +0 -11
  76. data/3.0-Upgrade.md +0 -70
  77. data/4.0-Upgrade.md +0 -53
  78. data/5.0-Upgrade.md +0 -56
  79. data/COMM-LICENSE +0 -97
  80. data/Ent-Changes.md +0 -238
  81. data/Gemfile +0 -23
  82. data/Pro-2.0-Upgrade.md +0 -138
  83. data/Pro-3.0-Upgrade.md +0 -44
  84. data/Pro-4.0-Upgrade.md +0 -35
  85. data/Pro-Changes.md +0 -759
  86. data/Rakefile +0 -9
  87. data/bin/sidekiqctl +0 -20
  88. data/code_of_conduct.md +0 -50
  89. data/lib/sidekiq/core_ext.rb +0 -1
  90. data/lib/sidekiq/ctl.rb +0 -221
  91. data/lib/sidekiq/logging.rb +0 -122
  92. data/lib/sidekiq/middleware/server/active_record.rb +0 -23
data/lib/sidekiq.rb CHANGED
@@ -1,27 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'sidekiq/version'
4
- 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')
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 'sidekiq/logging'
7
- require 'sidekiq/client'
8
- require 'sidekiq/worker'
9
- require 'sidekiq/redis_connection'
10
- require 'sidekiq/delay'
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 'json'
12
+ require "json"
13
13
 
14
14
  module Sidekiq
15
- NAME = 'Sidekiq'
16
- LICENSE = 'See LICENSE and the LGPL-3.0 for licensing details.'
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
+ strict: true,
23
24
  environment: nil,
24
- timeout: 8,
25
+ timeout: 25,
25
26
  poll_interval_average: nil,
26
27
  average_scheduled_poll_interval: 5,
27
28
  error_handlers: [],
@@ -30,16 +31,16 @@ module Sidekiq
30
31
  startup: [],
31
32
  quiet: [],
32
33
  shutdown: [],
33
- heartbeat: [],
34
+ heartbeat: []
34
35
  },
35
36
  dead_max_jobs: 10_000,
36
37
  dead_timeout_in_seconds: 180 * 24 * 60 * 60, # 6 months
37
- reloader: proc { |&block| block.call },
38
+ reloader: proc { |&block| block.call }
38
39
  }
39
40
 
40
41
  DEFAULT_WORKER_OPTIONS = {
41
- 'retry' => true,
42
- 'queue' => 'default'
42
+ "retry" => true,
43
+ "queue" => "default"
43
44
  }
44
45
 
45
46
  FAKE_INFO = {
@@ -95,10 +96,15 @@ module Sidekiq
95
96
  retryable = true
96
97
  begin
97
98
  yield conn
98
- rescue Redis::CommandError => ex
99
- #2550 Failover can cause the server to become a replica, need
99
+ rescue Redis::BaseError => ex
100
+ # 2550 Failover can cause the server to become a replica, need
100
101
  # to disconnect and reopen the socket to get back to the primary.
101
- (conn.disconnect!; retryable = false; retry) if retryable && ex.message =~ /READONLY/
102
+ # 4495 Use the same logic if we have a "Not enough replicas" error from the primary
103
+ if retryable && ex.message =~ /READONLY|NOREPLICAS/
104
+ conn.disconnect!
105
+ retryable = false
106
+ retry
107
+ end
102
108
  raise
103
109
  end
104
110
  end
@@ -106,19 +112,17 @@ module Sidekiq
106
112
 
107
113
  def self.redis_info
108
114
  redis do |conn|
109
- begin
110
- # admin commands can't go through redis-namespace starting
111
- # in redis-namespace 2.0
112
- if conn.respond_to?(:namespace)
113
- conn.redis.info
114
- else
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
115
+ # admin commands can't go through redis-namespace starting
116
+ # in redis-namespace 2.0
117
+ if conn.respond_to?(:namespace)
118
+ conn.redis.info
119
+ else
120
+ conn.info
121
121
  end
122
+ rescue Redis::CommandError => ex
123
+ # 2850 return fake version when INFO command has (probably) been renamed
124
+ raise unless /unknown command/.match?(ex.message)
125
+ FAKE_INFO
122
126
  end
123
127
  end
124
128
 
@@ -152,18 +156,13 @@ module Sidekiq
152
156
 
153
157
  def self.default_worker_options=(hash)
154
158
  # stringify
155
- @default_worker_options = default_worker_options.merge(Hash[hash.map{|k, v| [k.to_s, v]}])
159
+ @default_worker_options = default_worker_options.merge(hash.transform_keys(&:to_s))
156
160
  end
161
+
157
162
  def self.default_worker_options
158
163
  defined?(@default_worker_options) ? @default_worker_options : DEFAULT_WORKER_OPTIONS
159
164
  end
160
165
 
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
166
  ##
168
167
  # Death handlers are called when all retries for a job have been exhausted and
169
168
  # the job dies. It's the notification to your application
@@ -180,15 +179,41 @@ module Sidekiq
180
179
  def self.load_json(string)
181
180
  JSON.parse(string)
182
181
  end
182
+
183
183
  def self.dump_json(object)
184
184
  JSON.generate(object)
185
185
  end
186
186
 
187
+ def self.log_formatter
188
+ @log_formatter ||= if ENV["DYNO"]
189
+ Sidekiq::Logger::Formatters::WithoutTimestamp.new
190
+ else
191
+ Sidekiq::Logger::Formatters::Pretty.new
192
+ end
193
+ end
194
+
195
+ def self.log_formatter=(log_formatter)
196
+ @log_formatter = log_formatter
197
+ logger.formatter = log_formatter
198
+ end
199
+
187
200
  def self.logger
188
- Sidekiq::Logging.logger
201
+ @logger ||= Sidekiq::Logger.new($stdout, level: Logger::INFO)
189
202
  end
190
- def self.logger=(log)
191
- Sidekiq::Logging.logger = log
203
+
204
+ def self.logger=(logger)
205
+ if logger.nil?
206
+ self.logger.level = Logger::FATAL
207
+ return self.logger
208
+ end
209
+
210
+ logger.extend(Sidekiq::LoggingUtils)
211
+
212
+ @logger = logger
213
+ end
214
+
215
+ def self.pro?
216
+ defined?(Sidekiq::Pro)
192
217
  end
193
218
 
194
219
  # How frequently Redis should be checked by a random Sidekiq process for
@@ -197,7 +222,7 @@ module Sidekiq
197
222
  #
198
223
  # See sidekiq/scheduled.rb for an in-depth explanation of this value
199
224
  def self.average_scheduled_poll_interval=(interval)
200
- self.options[:average_scheduled_poll_interval] = interval
225
+ options[:average_scheduled_poll_interval] = interval
201
226
  end
202
227
 
203
228
  # Register a proc to handle any error which occurs within the Sidekiq process.
@@ -208,7 +233,7 @@ module Sidekiq
208
233
  #
209
234
  # The default error handler logs errors to Sidekiq.logger.
210
235
  def self.error_handlers
211
- self.options[:error_handlers]
236
+ options[:error_handlers]
212
237
  end
213
238
 
214
239
  # Register a block to run at a point in the Sidekiq lifecycle.
@@ -234,4 +259,4 @@ module Sidekiq
234
259
  class Shutdown < Interrupt; end
235
260
  end
236
261
 
237
- require 'sidekiq/rails' if defined?(::Rails::Engine)
262
+ require "sidekiq/rails" if defined?(::Rails::Engine)
data/sidekiq.gemspec CHANGED
@@ -1,21 +1,28 @@
1
- require_relative 'lib/sidekiq/version'
1
+ require_relative "lib/sidekiq/version"
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.authors = ["Mike Perham"]
5
- gem.email = ["mperham@gmail.com"]
6
- gem.summary = "Simple, efficient background processing for Ruby"
7
- gem.description = "Simple, efficient background processing for Ruby."
8
- gem.homepage = "http://sidekiq.org"
9
- gem.license = "LGPL-3.0"
4
+ gem.authors = ["Mike Perham"]
5
+ gem.email = ["mperham@gmail.com"]
6
+ gem.summary = "Simple, efficient background processing for Ruby"
7
+ gem.description = "Simple, efficient background processing for Ruby."
8
+ gem.homepage = "https://sidekiq.org"
9
+ gem.license = "LGPL-3.0"
10
10
 
11
- gem.executables = ['sidekiq', 'sidekiqctl']
12
- gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
13
- gem.name = "sidekiq"
14
- gem.version = Sidekiq::VERSION
15
- gem.required_ruby_version = ">= 2.2.2"
11
+ gem.executables = ["sidekiq", "sidekiqmon"]
12
+ gem.files = ["sidekiq.gemspec", "README.md", "Changes.md", "LICENSE"] + `git ls-files | grep -E '^(bin|lib|web)'`.split("\n")
13
+ gem.name = "sidekiq"
14
+ gem.version = Sidekiq::VERSION
15
+ gem.required_ruby_version = ">= 2.5.0"
16
16
 
17
- gem.add_dependency 'redis', '>= 3.3.5', '< 4.2'
18
- gem.add_dependency 'connection_pool', '~> 2.2', '>= 2.2.2'
19
- gem.add_dependency 'rack', '~> 2.0'
20
- gem.add_dependency 'rack-protection', '>= 1.5.0'
17
+ gem.metadata = {
18
+ "homepage_uri" => "https://sidekiq.org",
19
+ "bug_tracker_uri" => "https://github.com/mperham/sidekiq/issues",
20
+ "documentation_uri" => "https://github.com/mperham/sidekiq/wiki",
21
+ "changelog_uri" => "https://github.com/mperham/sidekiq/blob/master/Changes.md",
22
+ "source_code_uri" => "https://github.com/mperham/sidekiq"
23
+ }
24
+
25
+ gem.add_dependency "redis", ">= 4.2.0"
26
+ gem.add_dependency "connection_pool", ">= 2.2.2"
27
+ gem.add_dependency "rack", "~> 2.0"
21
28
  end