sidekiq 5.2.10 → 6.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +422 -1
- data/LICENSE +3 -3
- data/README.md +24 -35
- data/bin/sidekiq +27 -3
- data/bin/sidekiqload +79 -67
- data/bin/sidekiqmon +8 -0
- data/lib/generators/sidekiq/job_generator.rb +57 -0
- data/lib/generators/sidekiq/templates/{worker.rb.erb → job.rb.erb} +2 -2
- data/lib/generators/sidekiq/templates/{worker_spec.rb.erb → job_spec.rb.erb} +1 -1
- data/lib/generators/sidekiq/templates/{worker_test.rb.erb → job_test.rb.erb} +1 -1
- data/lib/sidekiq/api.rb +527 -310
- data/lib/sidekiq/cli.rb +204 -208
- data/lib/sidekiq/client.rb +78 -82
- data/lib/sidekiq/component.rb +65 -0
- data/lib/sidekiq/delay.rb +8 -7
- data/lib/sidekiq/extensions/action_mailer.rb +13 -22
- data/lib/sidekiq/extensions/active_record.rb +13 -10
- data/lib/sidekiq/extensions/class_methods.rb +14 -11
- data/lib/sidekiq/extensions/generic_proxy.rb +7 -5
- data/lib/sidekiq/fetch.rb +50 -40
- data/lib/sidekiq/job.rb +13 -0
- data/lib/sidekiq/job_logger.rb +33 -7
- data/lib/sidekiq/job_retry.rb +126 -106
- data/lib/sidekiq/job_util.rb +71 -0
- data/lib/sidekiq/launcher.rb +177 -83
- data/lib/sidekiq/logger.rb +156 -0
- data/lib/sidekiq/manager.rb +40 -41
- data/lib/sidekiq/metrics/deploy.rb +47 -0
- data/lib/sidekiq/metrics/query.rb +153 -0
- data/lib/sidekiq/metrics/shared.rb +94 -0
- data/lib/sidekiq/metrics/tracking.rb +134 -0
- data/lib/sidekiq/middleware/chain.rb +102 -46
- data/lib/sidekiq/middleware/current_attributes.rb +63 -0
- data/lib/sidekiq/middleware/i18n.rb +7 -7
- data/lib/sidekiq/middleware/modules.rb +21 -0
- data/lib/sidekiq/monitor.rb +133 -0
- data/lib/sidekiq/paginator.rb +28 -16
- data/lib/sidekiq/processor.rb +104 -97
- data/lib/sidekiq/rails.rb +46 -37
- data/lib/sidekiq/redis_client_adapter.rb +154 -0
- data/lib/sidekiq/redis_connection.rb +108 -77
- data/lib/sidekiq/ring_buffer.rb +29 -0
- data/lib/sidekiq/scheduled.rb +105 -42
- data/lib/sidekiq/sd_notify.rb +149 -0
- data/lib/sidekiq/systemd.rb +24 -0
- data/lib/sidekiq/testing/inline.rb +6 -5
- data/lib/sidekiq/testing.rb +68 -58
- data/lib/sidekiq/transaction_aware_client.rb +45 -0
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web/action.rb +15 -11
- data/lib/sidekiq/web/application.rb +103 -77
- data/lib/sidekiq/web/csrf_protection.rb +180 -0
- data/lib/sidekiq/web/helpers.rb +125 -95
- data/lib/sidekiq/web/router.rb +23 -19
- data/lib/sidekiq/web.rb +65 -105
- data/lib/sidekiq/worker.rb +259 -109
- data/lib/sidekiq.rb +170 -62
- data/sidekiq.gemspec +23 -16
- data/web/assets/images/apple-touch-icon.png +0 -0
- data/web/assets/javascripts/application.js +113 -61
- data/web/assets/javascripts/chart.min.js +13 -0
- data/web/assets/javascripts/chartjs-plugin-annotation.min.js +7 -0
- data/web/assets/javascripts/dashboard.js +53 -89
- data/web/assets/javascripts/graph.js +16 -0
- data/web/assets/javascripts/metrics.js +262 -0
- data/web/assets/stylesheets/application-dark.css +143 -0
- data/web/assets/stylesheets/application-rtl.css +0 -4
- data/web/assets/stylesheets/application.css +88 -233
- data/web/locales/ar.yml +8 -2
- data/web/locales/de.yml +14 -2
- data/web/locales/el.yml +43 -19
- data/web/locales/en.yml +13 -1
- data/web/locales/es.yml +18 -2
- data/web/locales/fr.yml +10 -3
- data/web/locales/ja.yml +14 -1
- data/web/locales/lt.yml +83 -0
- data/web/locales/pl.yml +4 -4
- data/web/locales/pt-br.yml +27 -9
- data/web/locales/ru.yml +4 -0
- data/web/locales/vi.yml +83 -0
- data/web/locales/zh-cn.yml +36 -11
- data/web/locales/zh-tw.yml +32 -7
- data/web/views/_footer.erb +1 -1
- data/web/views/_job_info.erb +3 -2
- data/web/views/_nav.erb +1 -1
- data/web/views/_poll_link.erb +2 -5
- data/web/views/_summary.erb +7 -7
- data/web/views/busy.erb +61 -22
- data/web/views/dashboard.erb +23 -14
- data/web/views/dead.erb +3 -3
- data/web/views/layout.erb +3 -1
- data/web/views/metrics.erb +69 -0
- data/web/views/metrics_for_job.erb +87 -0
- data/web/views/morgue.erb +9 -6
- data/web/views/queue.erb +23 -10
- data/web/views/queues.erb +10 -2
- data/web/views/retries.erb +11 -8
- data/web/views/retry.erb +3 -3
- data/web/views/scheduled.erb +5 -2
- metadata +58 -63
- data/.circleci/config.yml +0 -61
- data/.github/contributing.md +0 -32
- data/.github/issue_template.md +0 -11
- data/.gitignore +0 -15
- data/.travis.yml +0 -11
- data/3.0-Upgrade.md +0 -70
- data/4.0-Upgrade.md +0 -53
- data/5.0-Upgrade.md +0 -56
- data/COMM-LICENSE +0 -97
- data/Ent-Changes.md +0 -238
- data/Gemfile +0 -19
- data/Pro-2.0-Upgrade.md +0 -138
- data/Pro-3.0-Upgrade.md +0 -44
- data/Pro-4.0-Upgrade.md +0 -35
- data/Pro-Changes.md +0 -759
- data/Rakefile +0 -9
- data/bin/sidekiqctl +0 -20
- data/code_of_conduct.md +0 -50
- data/lib/generators/sidekiq/worker_generator.rb +0 -49
- data/lib/sidekiq/core_ext.rb +0 -1
- data/lib/sidekiq/ctl.rb +0 -221
- data/lib/sidekiq/exception_handler.rb +0 -29
- data/lib/sidekiq/logging.rb +0 -122
- data/lib/sidekiq/middleware/server/active_record.rb +0 -23
- data/lib/sidekiq/util.rb +0 -66
data/lib/sidekiq/web.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'erb'
|
3
2
|
|
4
|
-
require
|
5
|
-
require 'sidekiq/api'
|
6
|
-
require 'sidekiq/paginator'
|
7
|
-
require 'sidekiq/web/helpers'
|
3
|
+
require "erb"
|
8
4
|
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
5
|
+
require "sidekiq"
|
6
|
+
require "sidekiq/api"
|
7
|
+
require "sidekiq/paginator"
|
8
|
+
require "sidekiq/web/helpers"
|
12
9
|
|
13
|
-
require
|
10
|
+
require "sidekiq/web/router"
|
11
|
+
require "sidekiq/web/action"
|
12
|
+
require "sidekiq/web/application"
|
13
|
+
require "sidekiq/web/csrf_protection"
|
14
14
|
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
15
|
+
require "rack/content_length"
|
16
|
+
require "rack/builder"
|
17
|
+
require "rack/static"
|
18
18
|
|
19
19
|
module Sidekiq
|
20
20
|
class Web
|
@@ -25,27 +25,23 @@ module Sidekiq
|
|
25
25
|
ASSETS = "#{ROOT}/assets"
|
26
26
|
|
27
27
|
DEFAULT_TABS = {
|
28
|
-
"Dashboard" =>
|
29
|
-
"Busy"
|
30
|
-
"Queues"
|
31
|
-
"Retries"
|
32
|
-
"Scheduled" =>
|
33
|
-
"Dead"
|
28
|
+
"Dashboard" => "",
|
29
|
+
"Busy" => "busy",
|
30
|
+
"Queues" => "queues",
|
31
|
+
"Retries" => "retries",
|
32
|
+
"Scheduled" => "scheduled",
|
33
|
+
"Dead" => "morgue"
|
34
34
|
}
|
35
35
|
|
36
|
+
if ENV["SIDEKIQ_METRICS_BETA"] == "1"
|
37
|
+
DEFAULT_TABS["Metrics"] = "metrics"
|
38
|
+
end
|
39
|
+
|
36
40
|
class << self
|
37
41
|
def settings
|
38
42
|
self
|
39
43
|
end
|
40
44
|
|
41
|
-
def middlewares
|
42
|
-
@middlewares ||= []
|
43
|
-
end
|
44
|
-
|
45
|
-
def use(*middleware_args, &block)
|
46
|
-
middlewares << [middleware_args, block]
|
47
|
-
end
|
48
|
-
|
49
45
|
def default_tabs
|
50
46
|
DEFAULT_TABS
|
51
47
|
end
|
@@ -64,39 +60,52 @@ module Sidekiq
|
|
64
60
|
end
|
65
61
|
|
66
62
|
def enable(*opts)
|
67
|
-
opts.each {|key| set(key, true) }
|
63
|
+
opts.each { |key| set(key, true) }
|
68
64
|
end
|
69
65
|
|
70
66
|
def disable(*opts)
|
71
|
-
opts.each {|key| set(key, false) }
|
67
|
+
opts.each { |key| set(key, false) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def middlewares
|
71
|
+
@middlewares ||= []
|
72
|
+
end
|
73
|
+
|
74
|
+
def use(*args, &block)
|
75
|
+
middlewares << [args, block]
|
72
76
|
end
|
73
77
|
|
74
|
-
# Helper for the Sinatra syntax: Sidekiq::Web.set(:session_secret, Rails.application.secrets...)
|
75
78
|
def set(attribute, value)
|
76
79
|
send(:"#{attribute}=", value)
|
77
80
|
end
|
78
81
|
|
79
|
-
|
82
|
+
def sessions=(val)
|
83
|
+
puts "WARNING: Sidekiq::Web.sessions= is no longer relevant and will be removed in Sidekiq 7.0. #{caller(1..1).first}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def session_secret=(val)
|
87
|
+
puts "WARNING: Sidekiq::Web.session_secret= is no longer relevant and will be removed in Sidekiq 7.0. #{caller(1..1).first}"
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_accessor :app_url, :redis_pool
|
80
91
|
attr_writer :locales, :views
|
81
92
|
end
|
82
93
|
|
83
94
|
def self.inherited(child)
|
84
|
-
child.app_url =
|
85
|
-
child.
|
86
|
-
child.redis_pool = self.redis_pool
|
87
|
-
child.sessions = self.sessions
|
95
|
+
child.app_url = app_url
|
96
|
+
child.redis_pool = redis_pool
|
88
97
|
end
|
89
98
|
|
90
99
|
def settings
|
91
100
|
self.class.settings
|
92
101
|
end
|
93
102
|
|
94
|
-
def
|
95
|
-
middlewares
|
103
|
+
def middlewares
|
104
|
+
@middlewares ||= self.class.middlewares
|
96
105
|
end
|
97
106
|
|
98
|
-
def
|
99
|
-
|
107
|
+
def use(*args, &block)
|
108
|
+
middlewares << [args, block]
|
100
109
|
end
|
101
110
|
|
102
111
|
def call(env)
|
@@ -113,29 +122,19 @@ module Sidekiq
|
|
113
122
|
end
|
114
123
|
|
115
124
|
def enable(*opts)
|
116
|
-
opts.each {|key| set(key, true) }
|
125
|
+
opts.each { |key| set(key, true) }
|
117
126
|
end
|
118
127
|
|
119
128
|
def disable(*opts)
|
120
|
-
opts.each {|key| set(key, false) }
|
129
|
+
opts.each { |key| set(key, false) }
|
121
130
|
end
|
122
131
|
|
123
132
|
def set(attribute, value)
|
124
133
|
send(:"#{attribute}=", value)
|
125
134
|
end
|
126
135
|
|
127
|
-
|
128
|
-
|
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
|
136
|
+
def sessions=(val)
|
137
|
+
puts "Sidekiq::Web#sessions= is no longer relevant and will be removed in Sidekiq 7.0. #{caller[2..2].first}"
|
139
138
|
end
|
140
139
|
|
141
140
|
def self.register(extension)
|
@@ -144,50 +143,20 @@ module Sidekiq
|
|
144
143
|
|
145
144
|
private
|
146
145
|
|
147
|
-
def using?(middleware)
|
148
|
-
middlewares.any? do |(m,_)|
|
149
|
-
m.kind_of?(Array) && (m[0] == middleware || m[0].kind_of?(middleware))
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def build_sessions
|
154
|
-
middlewares = self.middlewares
|
155
|
-
|
156
|
-
unless using?(::Rack::Protection) || ENV['RACK_ENV'] == 'test'
|
157
|
-
middlewares.unshift [[::Rack::Protection, { use: :authenticity_token }], nil]
|
158
|
-
end
|
159
|
-
|
160
|
-
s = sessions
|
161
|
-
return unless s
|
162
|
-
|
163
|
-
unless using? ::Rack::Session::Cookie
|
164
|
-
unless secret = Web.session_secret
|
165
|
-
require 'securerandom'
|
166
|
-
secret = SecureRandom.hex(64)
|
167
|
-
end
|
168
|
-
|
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]
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
146
|
def build
|
177
|
-
build_sessions
|
178
|
-
|
179
|
-
middlewares = self.middlewares
|
180
147
|
klass = self.class
|
148
|
+
m = middlewares
|
181
149
|
|
182
|
-
|
183
|
-
|
184
|
-
map "/#{asset_dir}" do
|
185
|
-
run ::Rack::File.new("#{ASSETS}/#{asset_dir}", { 'Cache-Control' => 'public, max-age=86400' })
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
middlewares.each {|middleware, block| use(*middleware, &block) }
|
150
|
+
rules = []
|
151
|
+
rules = [[:all, {"cache-control" => "public, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"]
|
190
152
|
|
153
|
+
::Rack::Builder.new do
|
154
|
+
use Rack::Static, urls: ["/stylesheets", "/images", "/javascripts"],
|
155
|
+
root: ASSETS,
|
156
|
+
cascade: true,
|
157
|
+
header_rules: rules
|
158
|
+
m.each { |middleware, block| use(*middleware, &block) }
|
159
|
+
use Sidekiq::Web::CsrfProtection unless $TESTING
|
191
160
|
run WebApplication.new(klass)
|
192
161
|
end
|
193
162
|
end
|
@@ -196,18 +165,9 @@ module Sidekiq
|
|
196
165
|
Sidekiq::WebApplication.helpers WebHelpers
|
197
166
|
Sidekiq::WebApplication.helpers Sidekiq::Paginator
|
198
167
|
|
199
|
-
Sidekiq::WebAction.class_eval
|
200
|
-
|
201
|
-
|
202
|
-
if defined?(::ActionDispatch::Request::Session) &&
|
203
|
-
!::ActionDispatch::Request::Session.method_defined?(:each)
|
204
|
-
# mperham/sidekiq#2460
|
205
|
-
# Rack apps can't reuse the Rails session store without
|
206
|
-
# this monkeypatch, fixed in Rails 5.
|
207
|
-
class ActionDispatch::Request::Session
|
208
|
-
def each(&block)
|
209
|
-
hash = self.to_hash
|
210
|
-
hash.each(&block)
|
168
|
+
Sidekiq::WebAction.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
169
|
+
def _render
|
170
|
+
#{ERB.new(File.read(Web::LAYOUT)).src}
|
211
171
|
end
|
212
|
-
|
172
|
+
RUBY
|
213
173
|
end
|