sidekiq 0.10.0 → 7.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 +7 -0
- data/Changes.md +2082 -0
- data/LICENSE.txt +9 -0
- data/README.md +73 -27
- data/bin/sidekiq +25 -9
- data/bin/sidekiqload +247 -0
- data/bin/sidekiqmon +11 -0
- data/lib/generators/sidekiq/job_generator.rb +57 -0
- data/lib/generators/sidekiq/templates/job.rb.erb +9 -0
- data/lib/generators/sidekiq/templates/job_spec.rb.erb +6 -0
- data/lib/generators/sidekiq/templates/job_test.rb.erb +8 -0
- data/lib/sidekiq/api.rb +1145 -0
- data/lib/sidekiq/capsule.rb +127 -0
- data/lib/sidekiq/cli.rb +348 -109
- data/lib/sidekiq/client.rb +241 -41
- data/lib/sidekiq/component.rb +68 -0
- data/lib/sidekiq/config.rb +287 -0
- data/lib/sidekiq/deploy.rb +62 -0
- data/lib/sidekiq/embedded.rb +61 -0
- data/lib/sidekiq/fetch.rb +88 -0
- data/lib/sidekiq/job.rb +374 -0
- data/lib/sidekiq/job_logger.rb +51 -0
- data/lib/sidekiq/job_retry.rb +301 -0
- data/lib/sidekiq/job_util.rb +107 -0
- data/lib/sidekiq/launcher.rb +271 -0
- data/lib/sidekiq/logger.rb +131 -0
- data/lib/sidekiq/manager.rb +96 -103
- data/lib/sidekiq/metrics/query.rb +155 -0
- data/lib/sidekiq/metrics/shared.rb +95 -0
- data/lib/sidekiq/metrics/tracking.rb +136 -0
- data/lib/sidekiq/middleware/chain.rb +149 -38
- data/lib/sidekiq/middleware/current_attributes.rb +95 -0
- data/lib/sidekiq/middleware/i18n.rb +42 -0
- data/lib/sidekiq/middleware/modules.rb +21 -0
- data/lib/sidekiq/monitor.rb +146 -0
- data/lib/sidekiq/paginator.rb +55 -0
- data/lib/sidekiq/processor.rb +246 -61
- data/lib/sidekiq/rails.rb +60 -13
- data/lib/sidekiq/redis_client_adapter.rb +111 -0
- data/lib/sidekiq/redis_connection.rb +68 -15
- data/lib/sidekiq/ring_buffer.rb +29 -0
- data/lib/sidekiq/scheduled.rb +236 -0
- data/lib/sidekiq/sd_notify.rb +149 -0
- data/lib/sidekiq/systemd.rb +24 -0
- data/lib/sidekiq/testing/inline.rb +30 -0
- data/lib/sidekiq/testing.rb +310 -10
- data/lib/sidekiq/transaction_aware_client.rb +44 -0
- data/lib/sidekiq/version.rb +4 -1
- data/lib/sidekiq/web/action.rb +93 -0
- data/lib/sidekiq/web/application.rb +463 -0
- data/lib/sidekiq/web/csrf_protection.rb +180 -0
- data/lib/sidekiq/web/helpers.rb +364 -0
- data/lib/sidekiq/web/router.rb +104 -0
- data/lib/sidekiq/web.rb +143 -74
- data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
- data/lib/sidekiq.rb +120 -73
- data/sidekiq.gemspec +26 -23
- data/web/assets/images/apple-touch-icon.png +0 -0
- data/web/assets/images/favicon.ico +0 -0
- data/web/assets/images/logo.png +0 -0
- data/web/assets/images/status.png +0 -0
- data/web/assets/javascripts/application.js +177 -3
- data/web/assets/javascripts/base-charts.js +106 -0
- 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-charts.js +182 -0
- data/web/assets/javascripts/dashboard.js +57 -0
- data/web/assets/javascripts/metrics.js +298 -0
- data/web/assets/stylesheets/application-dark.css +147 -0
- data/web/assets/stylesheets/application-rtl.css +153 -0
- data/web/assets/stylesheets/application.css +729 -7
- data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
- data/web/assets/stylesheets/bootstrap.css +5 -0
- data/web/locales/ar.yml +87 -0
- data/web/locales/cs.yml +78 -0
- data/web/locales/da.yml +75 -0
- data/web/locales/de.yml +81 -0
- data/web/locales/el.yml +87 -0
- data/web/locales/en.yml +101 -0
- data/web/locales/es.yml +86 -0
- data/web/locales/fa.yml +80 -0
- data/web/locales/fr.yml +99 -0
- data/web/locales/gd.yml +99 -0
- data/web/locales/he.yml +80 -0
- data/web/locales/hi.yml +75 -0
- data/web/locales/it.yml +69 -0
- data/web/locales/ja.yml +91 -0
- data/web/locales/ko.yml +68 -0
- data/web/locales/lt.yml +83 -0
- data/web/locales/nb.yml +77 -0
- data/web/locales/nl.yml +68 -0
- data/web/locales/pl.yml +59 -0
- data/web/locales/pt-br.yml +96 -0
- data/web/locales/pt.yml +67 -0
- data/web/locales/ru.yml +83 -0
- data/web/locales/sv.yml +68 -0
- data/web/locales/ta.yml +75 -0
- data/web/locales/uk.yml +77 -0
- data/web/locales/ur.yml +80 -0
- data/web/locales/vi.yml +83 -0
- data/web/locales/zh-cn.yml +95 -0
- data/web/locales/zh-tw.yml +102 -0
- data/web/views/_footer.erb +23 -0
- data/web/views/_job_info.erb +105 -0
- data/web/views/_metrics_period_select.erb +12 -0
- data/web/views/_nav.erb +52 -0
- data/web/views/_paging.erb +25 -0
- data/web/views/_poll_link.erb +4 -0
- data/web/views/_status.erb +4 -0
- data/web/views/_summary.erb +40 -0
- data/web/views/busy.erb +148 -0
- data/web/views/dashboard.erb +105 -0
- data/web/views/dead.erb +34 -0
- data/web/views/filtering.erb +7 -0
- data/web/views/layout.erb +42 -0
- data/web/views/metrics.erb +91 -0
- data/web/views/metrics_for_job.erb +59 -0
- data/web/views/morgue.erb +74 -0
- data/web/views/queue.erb +55 -0
- data/web/views/queues.erb +44 -0
- data/web/views/retries.erb +79 -0
- data/web/views/retry.erb +34 -0
- data/web/views/scheduled.erb +56 -0
- data/web/views/scheduled_job_info.erb +8 -0
- metadata +159 -237
- data/.gitignore +0 -6
- data/.rvmrc +0 -4
- data/COMM-LICENSE +0 -75
- data/Gemfile +0 -10
- data/LICENSE +0 -22
- data/Rakefile +0 -9
- data/TODO.md +0 -1
- data/bin/client +0 -7
- data/bin/sidekiqctl +0 -43
- data/config.ru +0 -8
- data/examples/chef/cookbooks/sidekiq/README.rdoc +0 -11
- data/examples/chef/cookbooks/sidekiq/recipes/default.rb +0 -55
- data/examples/chef/cookbooks/sidekiq/templates/default/monitrc.conf.erb +0 -8
- data/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb +0 -219
- data/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.yml.erb +0 -22
- data/examples/config.yml +0 -9
- data/examples/monitrc.conf +0 -6
- data/examples/por.rb +0 -27
- data/examples/scheduling.rb +0 -37
- data/examples/sinkiq.rb +0 -57
- data/examples/web-ui.png +0 -0
- data/lib/sidekiq/capistrano.rb +0 -32
- data/lib/sidekiq/extensions/action_mailer.rb +0 -26
- data/lib/sidekiq/extensions/active_record.rb +0 -27
- data/lib/sidekiq/extensions/generic_proxy.rb +0 -21
- data/lib/sidekiq/middleware/client/unique_jobs.rb +0 -32
- data/lib/sidekiq/middleware/server/active_record.rb +0 -13
- data/lib/sidekiq/middleware/server/exception_handler.rb +0 -38
- data/lib/sidekiq/middleware/server/failure_jobs.rb +0 -24
- data/lib/sidekiq/middleware/server/logging.rb +0 -27
- data/lib/sidekiq/middleware/server/retry_jobs.rb +0 -59
- data/lib/sidekiq/middleware/server/unique_jobs.rb +0 -15
- data/lib/sidekiq/retry.rb +0 -57
- data/lib/sidekiq/util.rb +0 -61
- data/lib/sidekiq/worker.rb +0 -37
- data/myapp/.gitignore +0 -15
- data/myapp/Capfile +0 -5
- data/myapp/Gemfile +0 -19
- data/myapp/Gemfile.lock +0 -143
- data/myapp/Rakefile +0 -7
- data/myapp/app/controllers/application_controller.rb +0 -3
- data/myapp/app/controllers/work_controller.rb +0 -38
- data/myapp/app/helpers/application_helper.rb +0 -2
- data/myapp/app/mailers/.gitkeep +0 -0
- data/myapp/app/mailers/user_mailer.rb +0 -9
- data/myapp/app/models/.gitkeep +0 -0
- data/myapp/app/models/post.rb +0 -5
- data/myapp/app/views/layouts/application.html.erb +0 -14
- data/myapp/app/views/user_mailer/greetings.html.erb +0 -3
- data/myapp/app/views/work/index.html.erb +0 -1
- data/myapp/app/workers/hard_worker.rb +0 -9
- data/myapp/config/application.rb +0 -59
- data/myapp/config/boot.rb +0 -6
- data/myapp/config/database.yml +0 -25
- data/myapp/config/deploy.rb +0 -15
- data/myapp/config/environment.rb +0 -5
- data/myapp/config/environments/development.rb +0 -38
- data/myapp/config/environments/production.rb +0 -67
- data/myapp/config/environments/test.rb +0 -37
- data/myapp/config/initializers/backtrace_silencers.rb +0 -7
- data/myapp/config/initializers/inflections.rb +0 -15
- data/myapp/config/initializers/mime_types.rb +0 -5
- data/myapp/config/initializers/secret_token.rb +0 -7
- data/myapp/config/initializers/session_store.rb +0 -8
- data/myapp/config/initializers/sidekiq.rb +0 -6
- data/myapp/config/initializers/wrap_parameters.rb +0 -14
- data/myapp/config/locales/en.yml +0 -5
- data/myapp/config/routes.rb +0 -10
- data/myapp/config.ru +0 -4
- data/myapp/db/migrate/20120123214055_create_posts.rb +0 -10
- data/myapp/db/seeds.rb +0 -7
- data/myapp/lib/assets/.gitkeep +0 -0
- data/myapp/lib/tasks/.gitkeep +0 -0
- data/myapp/log/.gitkeep +0 -0
- data/myapp/script/rails +0 -6
- data/test/config.yml +0 -9
- data/test/fake_env.rb +0 -0
- data/test/helper.rb +0 -15
- data/test/test_cli.rb +0 -168
- data/test/test_client.rb +0 -105
- data/test/test_extensions.rb +0 -68
- data/test/test_manager.rb +0 -43
- data/test/test_middleware.rb +0 -92
- data/test/test_processor.rb +0 -32
- data/test/test_retry.rb +0 -83
- data/test/test_stats.rb +0 -78
- data/test/test_testing.rb +0 -65
- data/test/test_web.rb +0 -61
- data/web/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
- data/web/assets/images/bootstrap/glyphicons-halflings.png +0 -0
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-alert.js +0 -91
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-button.js +0 -98
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-carousel.js +0 -154
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-collapse.js +0 -136
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-dropdown.js +0 -92
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-modal.js +0 -210
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-popover.js +0 -95
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-scrollspy.js +0 -125
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-tab.js +0 -130
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-tooltip.js +0 -270
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-transition.js +0 -51
- data/web/assets/javascripts/vendor/bootstrap/bootstrap-typeahead.js +0 -271
- data/web/assets/javascripts/vendor/bootstrap.js +0 -12
- data/web/assets/javascripts/vendor/jquery.js +0 -9266
- data/web/assets/stylesheets/vendor/bootstrap-responsive.css +0 -567
- data/web/assets/stylesheets/vendor/bootstrap.css +0 -3365
- data/web/views/index.slim +0 -62
- data/web/views/layout.slim +0 -24
- data/web/views/queue.slim +0 -11
data/lib/sidekiq/web.rb
CHANGED
@@ -1,105 +1,174 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
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"
|
16
|
+
require "rack/builder"
|
17
|
+
require "rack/static"
|
4
18
|
|
5
19
|
module Sidekiq
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
class Web
|
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"
|
26
|
+
|
27
|
+
DEFAULT_TABS = {
|
28
|
+
"Dashboard" => "",
|
29
|
+
"Busy" => "busy",
|
30
|
+
"Queues" => "queues",
|
31
|
+
"Retries" => "retries",
|
32
|
+
"Scheduled" => "scheduled",
|
33
|
+
"Dead" => "morgue",
|
34
|
+
"Metrics" => "metrics"
|
35
|
+
}
|
36
|
+
|
37
|
+
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3")
|
38
|
+
CONTENT_LANGUAGE = "Content-Language"
|
39
|
+
CONTENT_SECURITY_POLICY = "Content-Security-Policy"
|
40
|
+
LOCATION = "Location"
|
41
|
+
X_CASCADE = "X-Cascade"
|
42
|
+
else
|
43
|
+
CONTENT_LANGUAGE = "content-language"
|
44
|
+
CONTENT_SECURITY_POLICY = "content-security-policy"
|
45
|
+
LOCATION = "location"
|
46
|
+
X_CASCADE = "x-cascade"
|
18
47
|
end
|
19
48
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
49
|
+
class << self
|
50
|
+
def settings
|
51
|
+
self
|
52
|
+
end
|
24
53
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
54
|
+
def default_tabs
|
55
|
+
DEFAULT_TABS
|
56
|
+
end
|
30
57
|
|
31
|
-
|
32
|
-
|
33
|
-
set :views, "#{dir}/views"
|
34
|
-
set :root, "#{dir}/public"
|
35
|
-
set :slim, :pretty => true
|
36
|
-
use SprocketsMiddleware, :root => dir
|
37
|
-
|
38
|
-
helpers do
|
39
|
-
def workers
|
40
|
-
@workers ||= begin
|
41
|
-
Sidekiq.redis do |conn|
|
42
|
-
conn.smembers('workers').map do |w|
|
43
|
-
msg = conn.get("worker:#{w}")
|
44
|
-
msg = MultiJson.decode(msg) if msg
|
45
|
-
[w, msg]
|
46
|
-
end.sort { |x| x[1] ? -1 : 1 }
|
47
|
-
end
|
48
|
-
end
|
58
|
+
def custom_tabs
|
59
|
+
@custom_tabs ||= {}
|
49
60
|
end
|
61
|
+
alias_method :tabs, :custom_tabs
|
50
62
|
|
51
|
-
def
|
52
|
-
|
63
|
+
def custom_job_info_rows
|
64
|
+
@custom_job_info_rows ||= []
|
53
65
|
end
|
54
66
|
|
55
|
-
def
|
56
|
-
|
67
|
+
def locales
|
68
|
+
@locales ||= LOCALES
|
57
69
|
end
|
58
70
|
|
59
|
-
def
|
60
|
-
|
71
|
+
def views
|
72
|
+
@views ||= VIEWS
|
61
73
|
end
|
62
74
|
|
63
|
-
def
|
64
|
-
|
65
|
-
results = conn.zrange('retry', 0, 25, :withscores => true)
|
66
|
-
results.each_slice(2).map { |msg, score| [MultiJson.decode(msg), Float(score)] }
|
67
|
-
end
|
75
|
+
def enable(*opts)
|
76
|
+
opts.each { |key| set(key, true) }
|
68
77
|
end
|
69
78
|
|
70
|
-
def
|
71
|
-
|
72
|
-
conn.smembers('queues').map do |q|
|
73
|
-
[q, conn.llen("queue:#{q}") || 0]
|
74
|
-
end.sort { |x,y| x[1] <=> y[1] }
|
75
|
-
end
|
79
|
+
def disable(*opts)
|
80
|
+
opts.each { |key| set(key, false) }
|
76
81
|
end
|
77
82
|
|
78
|
-
def
|
79
|
-
|
83
|
+
def middlewares
|
84
|
+
@middlewares ||= []
|
80
85
|
end
|
81
86
|
|
82
|
-
def
|
83
|
-
|
87
|
+
def use(*args, &block)
|
88
|
+
middlewares << [args, block]
|
84
89
|
end
|
85
90
|
|
86
|
-
def
|
87
|
-
|
88
|
-
return 'idle' if workers.size > 0 && workers.map { |x| x[1] }.compact.size == 0
|
89
|
-
return 'active'
|
91
|
+
def set(attribute, value)
|
92
|
+
send(:"#{attribute}=", value)
|
90
93
|
end
|
94
|
+
|
95
|
+
attr_accessor :app_url, :redis_pool
|
96
|
+
attr_writer :locales, :views
|
91
97
|
end
|
92
98
|
|
93
|
-
|
94
|
-
|
99
|
+
def self.inherited(child)
|
100
|
+
child.app_url = app_url
|
101
|
+
child.redis_pool = redis_pool
|
102
|
+
end
|
103
|
+
|
104
|
+
def settings
|
105
|
+
self.class.settings
|
106
|
+
end
|
107
|
+
|
108
|
+
def middlewares
|
109
|
+
@middlewares ||= self.class.middlewares
|
110
|
+
end
|
111
|
+
|
112
|
+
def use(*args, &block)
|
113
|
+
middlewares << [args, block]
|
114
|
+
end
|
115
|
+
|
116
|
+
def call(env)
|
117
|
+
app.call(env)
|
95
118
|
end
|
96
119
|
|
97
|
-
|
98
|
-
|
99
|
-
@
|
100
|
-
|
101
|
-
|
120
|
+
def self.call(env)
|
121
|
+
@app ||= new
|
122
|
+
@app.call(env)
|
123
|
+
end
|
124
|
+
|
125
|
+
def app
|
126
|
+
@app ||= build
|
127
|
+
end
|
128
|
+
|
129
|
+
def enable(*opts)
|
130
|
+
opts.each { |key| set(key, true) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def disable(*opts)
|
134
|
+
opts.each { |key| set(key, false) }
|
135
|
+
end
|
136
|
+
|
137
|
+
def set(attribute, value)
|
138
|
+
send(:"#{attribute}=", value)
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.register(extension)
|
142
|
+
extension.registered(WebApplication)
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
def build
|
148
|
+
klass = self.class
|
149
|
+
m = middlewares
|
150
|
+
|
151
|
+
rules = []
|
152
|
+
rules = [[:all, {Rack::CACHE_CONTROL => "private, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"]
|
153
|
+
|
154
|
+
::Rack::Builder.new do
|
155
|
+
use Rack::Static, urls: ["/stylesheets", "/images", "/javascripts"],
|
156
|
+
root: ASSETS,
|
157
|
+
cascade: true,
|
158
|
+
header_rules: rules
|
159
|
+
m.each { |middleware, block| use(*middleware, &block) }
|
160
|
+
use Sidekiq::Web::CsrfProtection unless $TESTING
|
161
|
+
run WebApplication.new(klass)
|
162
|
+
end
|
102
163
|
end
|
103
164
|
end
|
104
165
|
|
166
|
+
Sidekiq::WebApplication.helpers WebHelpers
|
167
|
+
Sidekiq::WebApplication.helpers Sidekiq::Paginator
|
168
|
+
|
169
|
+
Sidekiq::WebAction.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
170
|
+
def _render
|
171
|
+
#{ERB.new(File.read(Web::LAYOUT)).src}
|
172
|
+
end
|
173
|
+
RUBY
|
105
174
|
end
|
@@ -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
|
data/lib/sidekiq.rb
CHANGED
@@ -1,100 +1,147 @@
|
|
1
|
-
|
2
|
-
require 'sidekiq/client'
|
3
|
-
require 'sidekiq/worker'
|
4
|
-
require 'sidekiq/rails'
|
5
|
-
require 'sidekiq/redis_connection'
|
6
|
-
require 'sidekiq/util'
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
|
-
require
|
9
|
-
|
3
|
+
require "sidekiq/version"
|
4
|
+
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.7.0." if RUBY_PLATFORM != "java" && Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7.0")
|
5
|
+
|
6
|
+
begin
|
7
|
+
require "sidekiq-ent/version"
|
8
|
+
fail <<~EOM if Gem::Version.new(Sidekiq::Enterprise::VERSION).segments[0] != Sidekiq::MAJOR
|
9
|
+
|
10
|
+
Sidekiq Enterprise #{Sidekiq::Enterprise::VERSION} does not work with Sidekiq #{Sidekiq::VERSION}.
|
11
|
+
Starting with Sidekiq 7, major versions are synchronized so Sidekiq Enterprise 7 works with Sidekiq 7.
|
12
|
+
Use `bundle up sidekiq-ent` to upgrade.
|
13
|
+
|
14
|
+
EOM
|
15
|
+
rescue LoadError
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
require "sidekiq/pro/version"
|
20
|
+
fail <<~EOM if Gem::Version.new(Sidekiq::Pro::VERSION).segments[0] != Sidekiq::MAJOR
|
21
|
+
|
22
|
+
Sidekiq Pro #{Sidekiq::Pro::VERSION} does not work with Sidekiq #{Sidekiq::VERSION}.
|
23
|
+
Starting with Sidekiq 7, major versions are synchronized so Sidekiq Pro 7 works with Sidekiq 7.
|
24
|
+
Use `bundle up sidekiq-pro` to upgrade.
|
25
|
+
|
26
|
+
EOM
|
27
|
+
rescue LoadError
|
28
|
+
end
|
29
|
+
|
30
|
+
require "sidekiq/config"
|
31
|
+
require "sidekiq/logger"
|
32
|
+
require "sidekiq/client"
|
33
|
+
require "sidekiq/transaction_aware_client"
|
34
|
+
require "sidekiq/job"
|
35
|
+
require "sidekiq/worker_compatibility_alias"
|
36
|
+
require "sidekiq/redis_client_adapter"
|
37
|
+
|
38
|
+
require "json"
|
10
39
|
|
11
40
|
module Sidekiq
|
41
|
+
NAME = "Sidekiq"
|
42
|
+
LICENSE = "See LICENSE and the LGPL-3.0 for licensing details."
|
12
43
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:require => '.',
|
17
|
-
:environment => nil,
|
18
|
-
:timeout => 5,
|
19
|
-
:enable_rails_extensions => true,
|
20
|
-
}
|
44
|
+
def self.❨╯°□°❩╯︵┻━┻
|
45
|
+
puts "Take a deep breath and count to ten..."
|
46
|
+
end
|
21
47
|
|
22
|
-
def self.
|
23
|
-
|
48
|
+
def self.server?
|
49
|
+
defined?(Sidekiq::CLI)
|
24
50
|
end
|
25
51
|
|
26
|
-
def self.
|
27
|
-
|
52
|
+
def self.load_json(string)
|
53
|
+
JSON.parse(string)
|
28
54
|
end
|
29
55
|
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
# Sidekiq.configure_server do |config|
|
34
|
-
# config.redis = { :namespace => 'myapp', :size => 25, :url => 'redis://myhost:8877/mydb' }
|
35
|
-
# config.server_middleware do |chain|
|
36
|
-
# chain.add MyServerHook
|
37
|
-
# end
|
38
|
-
# end
|
39
|
-
def self.configure_server
|
40
|
-
yield self if server?
|
56
|
+
def self.dump_json(object)
|
57
|
+
JSON.generate(object)
|
41
58
|
end
|
42
59
|
|
43
|
-
|
44
|
-
|
45
|
-
#
|
46
|
-
# Sidekiq.configure_client do |config|
|
47
|
-
# config.redis = { :namespace => 'myapp', :size => 1, :url => 'redis://myhost:8877/mydb' }
|
48
|
-
# end
|
49
|
-
def self.configure_client
|
50
|
-
yield self unless server?
|
60
|
+
def self.pro?
|
61
|
+
defined?(Sidekiq::Pro)
|
51
62
|
end
|
52
63
|
|
53
|
-
def self.
|
54
|
-
defined?(Sidekiq::
|
64
|
+
def self.ent?
|
65
|
+
defined?(Sidekiq::Enterprise)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.redis_pool
|
69
|
+
(Thread.current[:sidekiq_capsule] || default_configuration).redis_pool
|
55
70
|
end
|
56
71
|
|
57
72
|
def self.redis(&block)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
73
|
+
(Thread.current[:sidekiq_capsule] || default_configuration).redis(&block)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.strict_args!(mode = :raise)
|
77
|
+
Sidekiq::Config::DEFAULTS[:on_complex_arguments] = mode
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.default_job_options=(hash)
|
81
|
+
@default_job_options = default_job_options.merge(hash.transform_keys(&:to_s))
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.default_job_options
|
85
|
+
@default_job_options ||= {"retry" => true, "queue" => "default"}
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.default_configuration
|
89
|
+
@config ||= Sidekiq::Config.new
|
90
|
+
end
|
64
91
|
|
65
|
-
|
92
|
+
def self.logger
|
93
|
+
default_configuration.logger
|
94
|
+
end
|
66
95
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@redis
|
71
|
-
end
|
96
|
+
def self.configure_server(&block)
|
97
|
+
(@config_blocks ||= []) << block
|
98
|
+
yield default_configuration if server?
|
72
99
|
end
|
73
100
|
|
74
|
-
def self.
|
75
|
-
@
|
76
|
-
|
77
|
-
else
|
78
|
-
Sidekiq::Util.logger.info "*****************************************************
|
79
|
-
Sidekiq.redis now takes a Hash:
|
80
|
-
old: Sidekiq.redis = Sidekiq::RedisConnection.create(:url => 'redis://foo.com', :namespace => 'abc', :size => 12)
|
81
|
-
new: Sidekiq.redis = { :url => 'redis://foo.com', :namespace => 'xyz', :size => 12 }
|
82
|
-
Called from #{caller[0]}
|
83
|
-
*****************************************************"
|
84
|
-
hash
|
85
|
-
end
|
101
|
+
def self.freeze!
|
102
|
+
@frozen = true
|
103
|
+
@config_blocks = nil
|
86
104
|
end
|
87
105
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
106
|
+
# Creates a Sidekiq::Config instance that is more tuned for embedding
|
107
|
+
# within an arbitrary Ruby process. Notably it reduces concurrency by
|
108
|
+
# default so there is less contention for CPU time with other threads.
|
109
|
+
#
|
110
|
+
# inst = Sidekiq.configure_embed do |config|
|
111
|
+
# config.queues = %w[critical default low]
|
112
|
+
# end
|
113
|
+
# inst.run
|
114
|
+
# sleep 10
|
115
|
+
# inst.terminate
|
116
|
+
#
|
117
|
+
# NB: it is really easy to overload a Ruby process with threads due to the GIL.
|
118
|
+
# I do not recommend setting concurrency higher than 2-3.
|
119
|
+
#
|
120
|
+
# NB: Sidekiq only supports one instance in memory. You will get undefined behavior
|
121
|
+
# if you try to embed Sidekiq twice in the same process.
|
122
|
+
def self.configure_embed(&block)
|
123
|
+
raise "Sidekiq global configuration is frozen, you must create all embedded instances BEFORE calling `run`" if @frozen
|
124
|
+
|
125
|
+
require "sidekiq/embedded"
|
126
|
+
cfg = default_configuration
|
127
|
+
cfg.concurrency = 2
|
128
|
+
@config_blocks&.each { |block| block.call(cfg) }
|
129
|
+
yield cfg
|
130
|
+
|
131
|
+
Sidekiq::Embedded.new(cfg)
|
92
132
|
end
|
93
133
|
|
94
|
-
def self.
|
95
|
-
|
96
|
-
yield @server_chain if block_given?
|
97
|
-
@server_chain
|
134
|
+
def self.configure_client
|
135
|
+
yield default_configuration unless server?
|
98
136
|
end
|
99
137
|
|
138
|
+
# We are shutting down Sidekiq but what about threads that
|
139
|
+
# are working on some long job? This error is
|
140
|
+
# raised in jobs that have not finished within the hard
|
141
|
+
# timeout limit. This is needed to rollback db transactions,
|
142
|
+
# otherwise Ruby's Thread#kill will commit. See #377.
|
143
|
+
# DO NOT RESCUE THIS ERROR IN YOUR JOBS
|
144
|
+
class Shutdown < Interrupt; end
|
100
145
|
end
|
146
|
+
|
147
|
+
require "sidekiq/rails" if defined?(::Rails::Engine)
|
data/sidekiq.gemspec
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
|
2
|
-
require File.expand_path('../lib/sidekiq/version', __FILE__)
|
1
|
+
require_relative "lib/sidekiq/version"
|
3
2
|
|
4
3
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors
|
6
|
-
gem.email
|
7
|
-
gem.
|
8
|
-
gem.
|
4
|
+
gem.authors = ["Mike Perham"]
|
5
|
+
gem.email = ["info@contribsys.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"
|
9
10
|
|
10
|
-
gem.executables
|
11
|
-
gem.files
|
12
|
-
gem.
|
13
|
-
gem.
|
14
|
-
gem.
|
15
|
-
|
16
|
-
gem.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
gem.
|
26
|
-
gem.
|
11
|
+
gem.executables = ["sidekiq", "sidekiqmon"]
|
12
|
+
gem.files = %w[sidekiq.gemspec README.md Changes.md LICENSE.txt] + `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.7.0"
|
16
|
+
|
17
|
+
gem.metadata = {
|
18
|
+
"homepage_uri" => "https://sidekiq.org",
|
19
|
+
"bug_tracker_uri" => "https://github.com/sidekiq/sidekiq/issues",
|
20
|
+
"documentation_uri" => "https://github.com/sidekiq/sidekiq/wiki",
|
21
|
+
"changelog_uri" => "https://github.com/sidekiq/sidekiq/blob/main/Changes.md",
|
22
|
+
"source_code_uri" => "https://github.com/sidekiq/sidekiq",
|
23
|
+
"rubygems_mfa_required" => "true"
|
24
|
+
}
|
25
|
+
|
26
|
+
gem.add_dependency "redis-client", ">= 0.14.0"
|
27
|
+
gem.add_dependency "connection_pool", ">= 2.3.0"
|
28
|
+
gem.add_dependency "rack", ">= 2.2.4"
|
29
|
+
gem.add_dependency "concurrent-ruby", "< 2"
|
27
30
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|