sidekiq 6.2.2 → 8.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changes.md +726 -11
- data/LICENSE.txt +9 -0
- data/README.md +70 -39
- data/bin/kiq +17 -0
- data/bin/lint-herb +13 -0
- data/bin/multi_queue_bench +271 -0
- data/bin/sidekiq +4 -9
- data/bin/sidekiqload +214 -115
- data/bin/sidekiqmon +4 -1
- data/bin/webload +69 -0
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +124 -0
- data/lib/generators/sidekiq/job_generator.rb +71 -0
- data/lib/generators/sidekiq/templates/{worker.rb.erb → job.rb.erb} +3 -3
- 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 +729 -264
- data/lib/sidekiq/capsule.rb +135 -0
- data/lib/sidekiq/cli.rb +124 -100
- data/lib/sidekiq/client.rb +153 -106
- data/lib/sidekiq/component.rb +132 -0
- data/lib/sidekiq/config.rb +320 -0
- data/lib/sidekiq/deploy.rb +64 -0
- data/lib/sidekiq/embedded.rb +64 -0
- data/lib/sidekiq/fetch.rb +27 -26
- data/lib/sidekiq/iterable_job.rb +56 -0
- data/lib/sidekiq/job/interrupt_handler.rb +24 -0
- data/lib/sidekiq/job/iterable/active_record_enumerator.rb +53 -0
- data/lib/sidekiq/job/iterable/csv_enumerator.rb +47 -0
- data/lib/sidekiq/job/iterable/enumerators.rb +135 -0
- data/lib/sidekiq/job/iterable.rb +322 -0
- data/lib/sidekiq/job.rb +397 -5
- data/lib/sidekiq/job_logger.rb +23 -32
- data/lib/sidekiq/job_retry.rb +141 -68
- data/lib/sidekiq/job_util.rb +113 -0
- data/lib/sidekiq/launcher.rb +122 -98
- data/lib/sidekiq/loader.rb +57 -0
- data/lib/sidekiq/logger.rb +27 -106
- data/lib/sidekiq/manager.rb +41 -43
- data/lib/sidekiq/metrics/query.rb +184 -0
- data/lib/sidekiq/metrics/shared.rb +109 -0
- data/lib/sidekiq/metrics/tracking.rb +153 -0
- data/lib/sidekiq/middleware/chain.rb +96 -51
- data/lib/sidekiq/middleware/current_attributes.rb +120 -0
- data/lib/sidekiq/middleware/i18n.rb +8 -4
- data/lib/sidekiq/middleware/modules.rb +23 -0
- data/lib/sidekiq/monitor.rb +16 -6
- data/lib/sidekiq/paginator.rb +37 -10
- data/lib/sidekiq/processor.rb +105 -87
- data/lib/sidekiq/profiler.rb +73 -0
- data/lib/sidekiq/rails.rb +49 -36
- data/lib/sidekiq/redis_client_adapter.rb +117 -0
- data/lib/sidekiq/redis_connection.rb +55 -86
- data/lib/sidekiq/ring_buffer.rb +32 -0
- data/lib/sidekiq/scheduled.rb +106 -50
- data/lib/sidekiq/systemd.rb +2 -0
- data/lib/sidekiq/test_api.rb +331 -0
- data/lib/sidekiq/testing/inline.rb +2 -30
- data/lib/sidekiq/testing.rb +2 -342
- data/lib/sidekiq/transaction_aware_client.rb +59 -0
- data/lib/sidekiq/tui/controls.rb +53 -0
- data/lib/sidekiq/tui/filtering.rb +53 -0
- data/lib/sidekiq/tui/tabs/base_tab.rb +204 -0
- data/lib/sidekiq/tui/tabs/busy.rb +118 -0
- data/lib/sidekiq/tui/tabs/dead.rb +19 -0
- data/lib/sidekiq/tui/tabs/home.rb +144 -0
- data/lib/sidekiq/tui/tabs/metrics.rb +131 -0
- data/lib/sidekiq/tui/tabs/queues.rb +95 -0
- data/lib/sidekiq/tui/tabs/retries.rb +19 -0
- data/lib/sidekiq/tui/tabs/scheduled.rb +19 -0
- data/lib/sidekiq/tui/tabs/set_tab.rb +96 -0
- data/lib/sidekiq/tui/tabs.rb +15 -0
- data/lib/sidekiq/tui.rb +382 -0
- data/lib/sidekiq/version.rb +6 -1
- data/lib/sidekiq/web/action.rb +149 -64
- data/lib/sidekiq/web/application.rb +376 -268
- data/lib/sidekiq/web/config.rb +117 -0
- data/lib/sidekiq/web/helpers.rb +213 -87
- data/lib/sidekiq/web/router.rb +61 -74
- data/lib/sidekiq/web.rb +71 -100
- data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
- data/lib/sidekiq.rb +95 -196
- data/sidekiq.gemspec +14 -11
- data/web/assets/images/logo.png +0 -0
- data/web/assets/images/status.png +0 -0
- data/web/assets/javascripts/application.js +171 -57
- data/web/assets/javascripts/base-charts.js +120 -0
- data/web/assets/javascripts/chart.min.js +13 -0
- data/web/assets/javascripts/chartjs-adapter-date-fns.min.js +7 -0
- data/web/assets/javascripts/chartjs-plugin-annotation.min.js +7 -0
- data/web/assets/javascripts/dashboard-charts.js +194 -0
- data/web/assets/javascripts/dashboard.js +41 -274
- data/web/assets/javascripts/metrics.js +280 -0
- data/web/assets/stylesheets/style.css +776 -0
- data/web/locales/ar.yml +72 -70
- data/web/locales/cs.yml +64 -62
- data/web/locales/da.yml +62 -53
- data/web/locales/de.yml +67 -65
- data/web/locales/el.yml +45 -24
- data/web/locales/en.yml +93 -69
- data/web/locales/es.yml +91 -68
- data/web/locales/fa.yml +67 -65
- data/web/locales/fr.yml +82 -67
- data/web/locales/gd.yml +110 -0
- data/web/locales/he.yml +67 -64
- data/web/locales/hi.yml +61 -59
- data/web/locales/it.yml +94 -54
- data/web/locales/ja.yml +74 -68
- data/web/locales/ko.yml +54 -52
- data/web/locales/lt.yml +68 -66
- data/web/locales/nb.yml +63 -61
- data/web/locales/nl.yml +54 -52
- data/web/locales/pl.yml +47 -45
- data/web/locales/{pt-br.yml → pt-BR.yml} +85 -56
- data/web/locales/pt.yml +53 -51
- data/web/locales/ru.yml +69 -66
- data/web/locales/sv.yml +55 -53
- data/web/locales/ta.yml +62 -60
- data/web/locales/tr.yml +102 -0
- data/web/locales/uk.yml +87 -61
- data/web/locales/ur.yml +66 -64
- data/web/locales/vi.yml +69 -67
- data/web/locales/zh-CN.yml +107 -0
- data/web/locales/{zh-tw.yml → zh-TW.yml} +44 -9
- data/web/views/_footer.html.erb +32 -0
- data/web/views/_job_info.html.erb +115 -0
- data/web/views/_metrics_period_select.html.erb +15 -0
- data/web/views/_nav.html.erb +45 -0
- data/web/views/_paging.html.erb +26 -0
- data/web/views/_poll_link.html.erb +4 -0
- data/web/views/_summary.html.erb +40 -0
- data/web/views/busy.html.erb +151 -0
- data/web/views/dashboard.html.erb +104 -0
- data/web/views/dead.html.erb +38 -0
- data/web/views/filtering.html.erb +6 -0
- data/web/views/layout.html.erb +26 -0
- data/web/views/metrics.html.erb +85 -0
- data/web/views/metrics_for_job.html.erb +58 -0
- data/web/views/morgue.html.erb +69 -0
- data/web/views/profiles.html.erb +43 -0
- data/web/views/queue.html.erb +57 -0
- data/web/views/queues.html.erb +46 -0
- data/web/views/retries.html.erb +77 -0
- data/web/views/retry.html.erb +39 -0
- data/web/views/scheduled.html.erb +64 -0
- data/web/views/{scheduled_job_info.erb → scheduled_job_info.html.erb} +3 -3
- metadata +130 -61
- data/LICENSE +0 -9
- data/lib/generators/sidekiq/worker_generator.rb +0 -57
- data/lib/sidekiq/delay.rb +0 -41
- data/lib/sidekiq/exception_handler.rb +0 -27
- data/lib/sidekiq/extensions/action_mailer.rb +0 -48
- data/lib/sidekiq/extensions/active_record.rb +0 -43
- data/lib/sidekiq/extensions/class_methods.rb +0 -43
- data/lib/sidekiq/extensions/generic_proxy.rb +0 -33
- data/lib/sidekiq/util.rb +0 -95
- data/lib/sidekiq/web/csrf_protection.rb +0 -180
- data/lib/sidekiq/worker.rb +0 -244
- data/web/assets/stylesheets/application-dark.css +0 -147
- data/web/assets/stylesheets/application-rtl.css +0 -246
- data/web/assets/stylesheets/application.css +0 -1053
- data/web/assets/stylesheets/bootstrap-rtl.min.css +0 -9
- data/web/assets/stylesheets/bootstrap.css +0 -5
- data/web/locales/zh-cn.yml +0 -68
- data/web/views/_footer.erb +0 -20
- data/web/views/_job_info.erb +0 -89
- data/web/views/_nav.erb +0 -52
- data/web/views/_paging.erb +0 -23
- data/web/views/_poll_link.erb +0 -7
- data/web/views/_status.erb +0 -4
- data/web/views/_summary.erb +0 -40
- data/web/views/busy.erb +0 -132
- data/web/views/dashboard.erb +0 -83
- data/web/views/dead.erb +0 -34
- data/web/views/layout.erb +0 -42
- data/web/views/morgue.erb +0 -78
- data/web/views/queue.erb +0 -55
- data/web/views/queues.erb +0 -38
- data/web/views/retries.erb +0 -83
- data/web/views/retry.erb +0 -34
- data/web/views/scheduled.erb +0 -57
data/lib/sidekiq/web/router.rb
CHANGED
|
@@ -3,101 +3,88 @@
|
|
|
3
3
|
require "rack"
|
|
4
4
|
|
|
5
5
|
module Sidekiq
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
PATCH = "PATCH"
|
|
12
|
-
HEAD = "HEAD"
|
|
13
|
-
|
|
14
|
-
ROUTE_PARAMS = "rack.route_params"
|
|
15
|
-
REQUEST_METHOD = "REQUEST_METHOD"
|
|
16
|
-
PATH_INFO = "PATH_INFO"
|
|
17
|
-
|
|
18
|
-
def head(path, &block)
|
|
19
|
-
route(HEAD, path, &block)
|
|
20
|
-
end
|
|
6
|
+
class Web
|
|
7
|
+
# Provides an API to declare endpoints, along with a match
|
|
8
|
+
# API to dynamically route a request to an endpoint.
|
|
9
|
+
module Router
|
|
10
|
+
def head(path, &) = route(:head, path, &)
|
|
21
11
|
|
|
22
|
-
|
|
23
|
-
route(GET, path, &block)
|
|
24
|
-
end
|
|
12
|
+
def get(path, &) = route(:get, path, &)
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
route(POST, path, &block)
|
|
28
|
-
end
|
|
14
|
+
def post(path, &) = route(:post, path, &)
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
route(PUT, path, &block)
|
|
32
|
-
end
|
|
16
|
+
def put(path, &) = route(:put, path, &)
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
route(PATCH, path, &block)
|
|
36
|
-
end
|
|
18
|
+
def patch(path, &) = route(:patch, path, &)
|
|
37
19
|
|
|
38
|
-
|
|
39
|
-
route(DELETE, path, &block)
|
|
40
|
-
end
|
|
20
|
+
def delete(path, &) = route(:delete, path, &)
|
|
41
21
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def match(env)
|
|
49
|
-
request_method = env[REQUEST_METHOD]
|
|
50
|
-
path_info = ::Rack::Utils.unescape env[PATH_INFO]
|
|
22
|
+
def route(*methods, path, &block)
|
|
23
|
+
methods.each do |method|
|
|
24
|
+
raise ArgumentError, "Invalid method #{method}. Must be one of #{@routes.keys.join(",")}" unless route_cache.has_key?(method)
|
|
25
|
+
route_cache[method] << Route.new(method, path, block)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
51
28
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
def match(env)
|
|
30
|
+
request_method = env["REQUEST_METHOD"].downcase.to_sym
|
|
31
|
+
path_info = ::Rack::Utils.unescape_path env["PATH_INFO"]
|
|
55
32
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if
|
|
59
|
-
env[ROUTE_PARAMS] = params
|
|
33
|
+
# There are servers which send an empty string when requesting the root.
|
|
34
|
+
# These servers should be ashamed of themselves.
|
|
35
|
+
path_info = "/" if path_info == ""
|
|
60
36
|
|
|
61
|
-
|
|
37
|
+
route_cache[request_method].each do |route|
|
|
38
|
+
params = route.match(request_method, path_info)
|
|
39
|
+
if params
|
|
40
|
+
env["rack.route_params"] = params
|
|
41
|
+
return Action.new(env, route.block)
|
|
42
|
+
end
|
|
62
43
|
end
|
|
44
|
+
|
|
45
|
+
nil
|
|
63
46
|
end
|
|
64
47
|
|
|
65
|
-
|
|
48
|
+
def route_cache
|
|
49
|
+
@@routes ||= {get: [], post: [], put: [], patch: [], delete: [], head: []}
|
|
50
|
+
end
|
|
66
51
|
end
|
|
67
|
-
end
|
|
68
52
|
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
class Route
|
|
54
|
+
attr_accessor :request_method, :pattern, :block, :name
|
|
71
55
|
|
|
72
|
-
|
|
56
|
+
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^.:$\/]+)/
|
|
73
57
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
58
|
+
def initialize(request_method, pattern, block)
|
|
59
|
+
@request_method = request_method
|
|
60
|
+
@pattern = pattern
|
|
61
|
+
@block = block
|
|
62
|
+
end
|
|
79
63
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
def matcher
|
|
65
|
+
@matcher ||= compile
|
|
66
|
+
end
|
|
83
67
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
68
|
+
def compile
|
|
69
|
+
if pattern.match?(NAMED_SEGMENTS_PATTERN)
|
|
70
|
+
p = pattern.gsub(NAMED_SEGMENTS_PATTERN, '/\1(?<\2>[^$/]+)')
|
|
87
71
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
Regexp.new("\\A#{p}\\Z")
|
|
73
|
+
else
|
|
74
|
+
pattern
|
|
75
|
+
end
|
|
91
76
|
end
|
|
92
|
-
end
|
|
93
77
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
EMPTY = {}.freeze
|
|
79
|
+
|
|
80
|
+
def match(request_method, path)
|
|
81
|
+
case matcher
|
|
82
|
+
when String
|
|
83
|
+
EMPTY if path == matcher
|
|
84
|
+
else
|
|
85
|
+
path_match = path.match(matcher)
|
|
86
|
+
path_match&.named_captures&.transform_keys(&:to_sym)
|
|
87
|
+
end
|
|
101
88
|
end
|
|
102
89
|
end
|
|
103
90
|
end
|
data/lib/sidekiq/web.rb
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "erb"
|
|
4
|
-
|
|
5
|
-
require "sidekiq"
|
|
6
|
-
require "sidekiq/api"
|
|
7
|
-
require "sidekiq/paginator"
|
|
8
|
-
require "sidekiq/web/helpers"
|
|
9
|
-
|
|
10
|
-
require "sidekiq/web/router"
|
|
11
|
-
require "sidekiq/web/action"
|
|
12
|
-
require "sidekiq/web/application"
|
|
13
|
-
require "sidekiq/web/csrf_protection"
|
|
14
|
-
|
|
15
|
-
require "rack/content_length"
|
|
4
|
+
require "securerandom"
|
|
16
5
|
require "rack/builder"
|
|
17
6
|
require "rack/static"
|
|
7
|
+
require "sidekiq"
|
|
8
|
+
require "sidekiq/api"
|
|
9
|
+
require "sidekiq/web/config"
|
|
18
10
|
|
|
19
11
|
module Sidekiq
|
|
20
12
|
class Web
|
|
21
13
|
ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../web")
|
|
22
14
|
VIEWS = "#{ROOT}/views"
|
|
23
15
|
LOCALES = ["#{ROOT}/locales"]
|
|
24
|
-
LAYOUT = "#{VIEWS}/layout.erb"
|
|
16
|
+
LAYOUT = "#{VIEWS}/layout.html.erb"
|
|
25
17
|
ASSETS = "#{ROOT}/assets"
|
|
26
18
|
|
|
27
19
|
DEFAULT_TABS = {
|
|
@@ -30,140 +22,119 @@ module Sidekiq
|
|
|
30
22
|
"Queues" => "queues",
|
|
31
23
|
"Retries" => "retries",
|
|
32
24
|
"Scheduled" => "scheduled",
|
|
33
|
-
"Dead" => "morgue"
|
|
25
|
+
"Dead" => "morgue",
|
|
26
|
+
"Metrics" => "metrics",
|
|
27
|
+
"Profiles" => "profiles"
|
|
34
28
|
}
|
|
35
29
|
|
|
30
|
+
@@config = Sidekiq::Web::Config.new
|
|
31
|
+
|
|
36
32
|
class << self
|
|
37
|
-
def
|
|
38
|
-
|
|
33
|
+
def configure
|
|
34
|
+
if block_given?
|
|
35
|
+
yield @@config
|
|
36
|
+
else
|
|
37
|
+
@@config
|
|
38
|
+
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def
|
|
42
|
-
|
|
41
|
+
def app_url=(url)
|
|
42
|
+
@@config.app_url = url
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def
|
|
46
|
-
|
|
45
|
+
def assets_path=(path)
|
|
46
|
+
@@config.assets_path = path
|
|
47
47
|
end
|
|
48
|
-
alias_method :tabs, :custom_tabs
|
|
49
48
|
|
|
50
|
-
def
|
|
51
|
-
@locales ||= LOCALES
|
|
52
|
-
end
|
|
49
|
+
def assets_path = @@config.assets_path
|
|
53
50
|
|
|
54
|
-
def
|
|
55
|
-
@views ||= VIEWS
|
|
56
|
-
end
|
|
51
|
+
def tabs = @@config.tabs
|
|
57
52
|
|
|
58
|
-
def
|
|
59
|
-
opts.each { |key| set(key, true) }
|
|
60
|
-
end
|
|
53
|
+
def locales = @@config.locales
|
|
61
54
|
|
|
62
|
-
def
|
|
63
|
-
opts.each { |key| set(key, false) }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def middlewares
|
|
67
|
-
@middlewares ||= []
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def use(*args, &block)
|
|
71
|
-
middlewares << [args, block]
|
|
72
|
-
end
|
|
55
|
+
def views = @@config.views
|
|
73
56
|
|
|
74
|
-
def
|
|
75
|
-
send(:"#{attribute}=", value)
|
|
76
|
-
end
|
|
57
|
+
def custom_job_info_rows = @@config.custom_job_info_rows
|
|
77
58
|
|
|
78
|
-
def
|
|
79
|
-
|
|
59
|
+
def redis_pool
|
|
60
|
+
@pool || Sidekiq.default_configuration.redis_pool
|
|
80
61
|
end
|
|
81
62
|
|
|
82
|
-
def
|
|
83
|
-
|
|
63
|
+
def redis_pool=(pool)
|
|
64
|
+
@pool = pool
|
|
84
65
|
end
|
|
85
66
|
|
|
86
|
-
|
|
87
|
-
attr_writer :locales, :views
|
|
88
|
-
end
|
|
67
|
+
def middlewares = @@config.middlewares
|
|
89
68
|
|
|
90
|
-
|
|
91
|
-
child.app_url = app_url
|
|
92
|
-
child.redis_pool = redis_pool
|
|
93
|
-
end
|
|
69
|
+
def use(*args, &block) = @@config.middlewares << [args, block]
|
|
94
70
|
|
|
95
|
-
|
|
96
|
-
|
|
71
|
+
def register(*args, **kw, &block)
|
|
72
|
+
Sidekiq.logger.warn { "`Sidekiq::Web.register` is deprecated, use `Sidekiq::Web.configure {|cfg| cfg.register(...) }`" }
|
|
73
|
+
@@config.register(*args, **kw, &block)
|
|
74
|
+
end
|
|
97
75
|
end
|
|
98
76
|
|
|
99
|
-
|
|
100
|
-
|
|
77
|
+
# Allow user to say
|
|
78
|
+
# run Sidekiq::Web
|
|
79
|
+
# rather than:
|
|
80
|
+
# run Sidekiq::Web.new
|
|
81
|
+
def self.call(env)
|
|
82
|
+
@inst ||= new
|
|
83
|
+
@inst.call(env)
|
|
101
84
|
end
|
|
102
85
|
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
# testing, internal use only
|
|
87
|
+
def self.reset!
|
|
88
|
+
@@config.reset!
|
|
89
|
+
@inst = nil
|
|
105
90
|
end
|
|
106
91
|
|
|
107
92
|
def call(env)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
@app ||= new
|
|
113
|
-
@app.call(env)
|
|
93
|
+
env[:web_config] = Sidekiq::Web.configure
|
|
94
|
+
env[:csp_nonce] = SecureRandom.hex(8)
|
|
95
|
+
env[:redis_pool] = self.class.redis_pool
|
|
96
|
+
safe_request?(env) ? app.call(env) : deny(env)
|
|
114
97
|
end
|
|
115
98
|
|
|
116
99
|
def app
|
|
117
|
-
@app ||= build
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def enable(*opts)
|
|
121
|
-
opts.each { |key| set(key, true) }
|
|
100
|
+
@app ||= build(@@config)
|
|
122
101
|
end
|
|
123
102
|
|
|
124
|
-
def
|
|
125
|
-
|
|
103
|
+
def safe_methods?(env)
|
|
104
|
+
%w[GET HEAD OPTIONS TRACE].include? env["REQUEST_METHOD"]
|
|
126
105
|
end
|
|
127
106
|
|
|
128
|
-
def
|
|
129
|
-
|
|
107
|
+
def safe_request?(env)
|
|
108
|
+
return true if safe_methods?(env)
|
|
109
|
+
env["HTTP_SEC_FETCH_SITE"] == "same-origin"
|
|
130
110
|
end
|
|
131
111
|
|
|
132
|
-
def
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def self.register(extension)
|
|
137
|
-
extension.registered(WebApplication)
|
|
112
|
+
def deny(env)
|
|
113
|
+
Sidekiq.logger.warn "attack prevented by #{self.class}"
|
|
114
|
+
[403, {Rack::CONTENT_TYPE => "text/plain"}, ["Forbidden"]]
|
|
138
115
|
end
|
|
139
116
|
|
|
140
117
|
private
|
|
141
118
|
|
|
142
|
-
def build
|
|
143
|
-
|
|
144
|
-
m = middlewares
|
|
119
|
+
def build(cfg)
|
|
120
|
+
cfg.freeze
|
|
121
|
+
m = cfg.middlewares
|
|
145
122
|
|
|
146
123
|
rules = []
|
|
147
|
-
rules = [[:all, {"
|
|
124
|
+
rules = [[:all, {"cache-control" => "private, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"]
|
|
148
125
|
|
|
149
126
|
::Rack::Builder.new do
|
|
150
127
|
use Rack::Static, urls: ["/stylesheets", "/images", "/javascripts"],
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
128
|
+
root: cfg.assets_path,
|
|
129
|
+
cascade: true,
|
|
130
|
+
header_rules: rules
|
|
154
131
|
m.each { |middleware, block| use(*middleware, &block) }
|
|
155
|
-
|
|
156
|
-
run WebApplication.new(klass)
|
|
132
|
+
run Sidekiq::Web::Application.new(self.class)
|
|
157
133
|
end
|
|
158
134
|
end
|
|
159
135
|
end
|
|
160
|
-
|
|
161
|
-
Sidekiq::WebApplication.helpers WebHelpers
|
|
162
|
-
Sidekiq::WebApplication.helpers Sidekiq::Paginator
|
|
163
|
-
|
|
164
|
-
Sidekiq::WebAction.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
165
|
-
def _render
|
|
166
|
-
#{ERB.new(File.read(Web::LAYOUT)).src}
|
|
167
|
-
end
|
|
168
|
-
RUBY
|
|
169
136
|
end
|
|
137
|
+
|
|
138
|
+
require "sidekiq/web/router"
|
|
139
|
+
require "sidekiq/web/action"
|
|
140
|
+
require "sidekiq/web/application"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sidekiq
|
|
4
|
+
# Sidekiq::Job is a new alias for Sidekiq::Worker as of Sidekiq 6.3.0.
|
|
5
|
+
# Use `include Sidekiq::Job` rather than `include Sidekiq::Worker`.
|
|
6
|
+
#
|
|
7
|
+
# The term "worker" is too generic and overly confusing, used in several
|
|
8
|
+
# different contexts meaning different things. Many people call a Sidekiq
|
|
9
|
+
# process a "worker". Some people call the thread that executes jobs a
|
|
10
|
+
# "worker". This change brings Sidekiq closer to ActiveJob where your job
|
|
11
|
+
# classes extend ApplicationJob.
|
|
12
|
+
Worker = Job
|
|
13
|
+
end
|