sidekiq 7.3.5 → 7.3.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ada259b22664fbbb740c3d28fa06578cb6fc00a42590ea459a1f2395f8e38a92
4
- data.tar.gz: 0636466a99e8a0df4d955b0928d76b504df74bba4e3ab13a2d08237ccd57b162
3
+ metadata.gz: ec7c9a4bea6982200a069a9a2f7c134811ccbf1aaceb56a8cb708893cab6e301
4
+ data.tar.gz: e59152e78eccbf714e485a7772e3a62681974abd114ebd608432c5ab93f55211
5
5
  SHA512:
6
- metadata.gz: 209f76b8ceebdb2cac83d22aab78873dad373a9ba488e7d320972e8ced4d3ac71454ef6669db321727ce3e4a85fdc5744005ff64d1a0f4cd48d9a4231bddf384
7
- data.tar.gz: df094fd4baa169249e92309814d67d0fb5a53b5da4990c0510f5ae1d96e07541356a3014f75b8b79a97f0a91b03b92b576331422c54f36bb2c4943f2f0f87b08
6
+ metadata.gz: 5aac99a9f1a385baaac0204c2799b9821c2146ca045eb2cdabc92ac54da8f20ae6239183eed5256bd96e8c45a8538596aa13714f5dc8fb4943565ec86df16dc9
7
+ data.tar.gz: 7ae68faedfc60d2354335709e36b51d9217bead4bfcf2e2d9d60a4b321cfcafdf931680f298bae061ac412e26d898b82dc7c7f15549909834f93251f7745bb13
data/Changes.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
+ 7.3.8
6
+ ----------
7
+
8
+ - Fix dead tag links [#6554]
9
+ - Massive Web UI performance improvement, some pages up to 15x faster [#6555]
10
+
11
+ 7.3.7
12
+ ----------
13
+
14
+ - Backport `Sidekiq::Web.configure` for compatibility with 8.0 [#6532]
15
+ - Backport `url_params(key)` and `route_params(key)` for compatibility with 8.0 [#6532]
16
+ - Various fixes for UI filtering [#6508]
17
+ - Tune `inspect` for internal S::Components to keep size managable [#6553]
18
+
19
+ 7.3.6
20
+ ----------
21
+
22
+ - Forward compatibility fixes for Ruby 3.4
23
+ - Filtering in the Web UI now works via GET so you can bookmark a filtered view. [#6497]
24
+
5
25
  7.3.5
6
26
  ----------
7
27
 
data/bin/sidekiqload CHANGED
@@ -50,7 +50,7 @@ if ENV["AJ"]
50
50
  ActiveJob::Base.logger.level = Logger::WARN
51
51
 
52
52
  class LoadJob < ActiveJob::Base
53
- def perform(idx, ts = nil)
53
+ def perform(string, idx, hash, ts = nil)
54
54
  puts(Time.now.to_f - ts) if !ts.nil?
55
55
  end
56
56
  end
@@ -58,12 +58,21 @@ end
58
58
 
59
59
  class LoadWorker
60
60
  include Sidekiq::Job
61
+ $count = 0
62
+ $lock = Mutex.new
63
+
61
64
  sidekiq_options retry: 1
62
65
  sidekiq_retry_in do |x|
63
66
  1
64
67
  end
65
68
 
66
- def perform(idx, ts = nil)
69
+ def perform(string, idx, hash, ts = nil)
70
+ $lock.synchronize do
71
+ $count += 1
72
+ if $count % 100_000 == 0
73
+ logger.warn("#{Time.now} Done #{$count}")
74
+ end
75
+ end
67
76
  puts(Time.now.to_f - ts) if !ts.nil?
68
77
  # raise idx.to_s if idx % 100 == 1
69
78
  end
@@ -133,13 +142,13 @@ class Loader
133
142
  start = Time.now
134
143
  if ENV["AJ"]
135
144
  @iter.times do
136
- @count.times do |idx|
137
- LoadJob.perform_later(idx)
138
- end
145
+ ActiveJob.perform_all_later(@count.times.map do |idx|
146
+ LoadJob.new("mike", idx, {mike: "bob"})
147
+ end)
139
148
  end
140
149
  else
141
150
  @iter.times do
142
- arr = Array.new(@count) { |idx| [idx] }
151
+ arr = Array.new(@count) { |idx| ["string", idx, {"mike" => "bob"}] }
143
152
  Sidekiq::Client.push_bulk("class" => LoadWorker, "args" => arr)
144
153
  end
145
154
  end
@@ -163,13 +172,13 @@ class Loader
163
172
  Sidekiq.logger.error("Now here's the latency for three jobs")
164
173
 
165
174
  if ENV["AJ"]
166
- LoadJob.perform_later(1, Time.now.to_f)
167
- LoadJob.perform_later(2, Time.now.to_f)
168
- LoadJob.perform_later(3, Time.now.to_f)
175
+ LoadJob.perform_later("", 1, {}, Time.now.to_f)
176
+ LoadJob.perform_later("", 2, {}, Time.now.to_f)
177
+ LoadJob.perform_later("", 3, {}, Time.now.to_f)
169
178
  else
170
- LoadWorker.perform_async(1, Time.now.to_f)
171
- LoadWorker.perform_async(2, Time.now.to_f)
172
- LoadWorker.perform_async(3, Time.now.to_f)
179
+ LoadWorker.perform_async("", 1, {}, Time.now.to_f)
180
+ LoadWorker.perform_async("", 2, {}, Time.now.to_f)
181
+ LoadWorker.perform_async("", 3, {}, Time.now.to_f)
173
182
  end
174
183
 
175
184
  sleep 0.1
@@ -16,7 +16,7 @@ end
16
16
  module ActiveJob
17
17
  module QueueAdapters
18
18
  # Explicitly remove the implementation existing in older rails'.
19
- remove_const(:SidekiqAdapter) if defined?("::#{name}::SidekiqAdapter")
19
+ remove_const(:SidekiqAdapter) if const_defined?(:SidekiqAdapter)
20
20
 
21
21
  # Sidekiq adapter for Active Job
22
22
  #
data/lib/sidekiq/cli.rb CHANGED
@@ -101,7 +101,7 @@ module Sidekiq # :nodoc:
101
101
  # Touch middleware so it isn't lazy loaded by multiple threads, #3043
102
102
  @config.server_middleware
103
103
 
104
- ::Process.warmup if warmup && ::Process.respond_to?(:warmup)
104
+ ::Process.warmup if warmup && ::Process.respond_to?(:warmup) && ENV["RUBY_DISABLE_WARMUP"] != "1"
105
105
 
106
106
  # Before this point, the process is initializing with just the main thread.
107
107
  # Starting here the process will now have multiple threads running.
@@ -64,5 +64,27 @@ module Sidekiq
64
64
  end
65
65
  arr.clear if oneshot # once we've fired an event, we never fire it again
66
66
  end
67
+
68
+ # When you have a large tree of components, the `inspect` output
69
+ # can get out of hand, especially with lots of Sidekiq::Config
70
+ # references everywhere. We avoid calling `inspect` on more complex
71
+ # state and use `to_s` instead to keep output manageable, #6553
72
+ def inspect
73
+ "#<#{self.class.name} #{
74
+ instance_variables.map do |name|
75
+ value = instance_variable_get(name)
76
+ case value
77
+ when Proc
78
+ "#{name}=#{value}"
79
+ when Sidekiq::Config
80
+ "#{name}=#{value}"
81
+ when Sidekiq::Component
82
+ "#{name}=#{value}"
83
+ else
84
+ "#{name}=#{value.inspect}"
85
+ end
86
+ end.join(", ")
87
+ }>"
88
+ end
67
89
  end
68
90
  end
@@ -61,6 +61,12 @@ module Sidekiq
61
61
  def_delegators :@options, :[], :[]=, :fetch, :key?, :has_key?, :merge!, :dig
62
62
  attr_reader :capsules
63
63
 
64
+ def inspect
65
+ "#<#{self.class.name} @options=#{
66
+ @options.except(:lifecycle_events, :reloader, :death_handlers, :error_handlers).inspect
67
+ }>"
68
+ end
69
+
64
70
  def to_json(*)
65
71
  Sidekiq.dump_json(@options)
66
72
  end
@@ -2,6 +2,12 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Paginator
5
+ TYPE_CACHE = {
6
+ "dead" => "zset",
7
+ "retry" => "zset",
8
+ "schedule" => "zset"
9
+ }
10
+
5
11
  def page(key, pageidx = 1, page_size = 25, opts = nil)
6
12
  current_page = (pageidx.to_i < 1) ? 1 : pageidx.to_i
7
13
  pageidx = current_page - 1
data/lib/sidekiq/rails.rb CHANGED
@@ -38,9 +38,9 @@ module Sidekiq
38
38
  # end
39
39
  # end
40
40
  initializer "sidekiq.active_job_integration" do
41
- ActiveSupport.on_load(:active_job) do
42
- require "active_job/queue_adapters/sidekiq_adapter"
41
+ require "active_job/queue_adapters/sidekiq_adapter"
43
42
 
43
+ ActiveSupport.on_load(:active_job) do
44
44
  include ::Sidekiq::Job::Options unless respond_to?(:sidekiq_options)
45
45
  end
46
46
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "7.3.5"
4
+ VERSION = "7.3.8"
5
5
  MAJOR = 7
6
6
 
7
7
  def self.gem_version
@@ -27,6 +27,7 @@ module Sidekiq
27
27
  redirect current_location
28
28
  end
29
29
 
30
+ # deprecated, will warn in 8.0
30
31
  def params
31
32
  indifferent_hash = Hash.new { |hash, key| hash[key.to_s] if Symbol === key }
32
33
 
@@ -36,8 +37,19 @@ module Sidekiq
36
37
  indifferent_hash
37
38
  end
38
39
 
39
- def route_params
40
- env[WebRouter::ROUTE_PARAMS]
40
+ # Use like `url_params("page")` within your action blocks
41
+ def url_params(key)
42
+ request.params[key]
43
+ end
44
+
45
+ # Use like `route_params(:name)` within your action blocks
46
+ # key is required in 8.0, nil is only used for backwards compatibility
47
+ def route_params(key = nil)
48
+ if key
49
+ env[WebRouter::ROUTE_PARAMS][key]
50
+ else
51
+ env[WebRouter::ROUTE_PARAMS]
52
+ end
41
53
  end
42
54
 
43
55
  def session
@@ -67,11 +67,15 @@ module Sidekiq
67
67
  end
68
68
 
69
69
  get "/metrics" do
70
+ x = params[:substr]
71
+ class_filter = (x.nil? || x == "") ? nil : Regexp.new(Regexp.escape(x), Regexp::IGNORECASE)
72
+
70
73
  q = Sidekiq::Metrics::Query.new
71
74
  @period = h((params[:period] || "")[0..1])
72
75
  @periods = METRICS_PERIODS
73
76
  minutes = @periods.fetch(@period, @periods.values.first)
74
- @query_result = q.top_jobs(minutes: minutes)
77
+ @query_result = q.top_jobs(minutes: minutes, class_filter: class_filter)
78
+
75
79
  erb(:metrics)
76
80
  end
77
81
 
@@ -153,9 +157,15 @@ module Sidekiq
153
157
  end
154
158
 
155
159
  get "/morgue" do
156
- @count = (params["count"] || 25).to_i
157
- (@current_page, @total_size, @dead) = page("dead", params["page"], @count, reverse: true)
158
- @dead = @dead.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
160
+ x = params[:substr]
161
+
162
+ if x && x != ""
163
+ @dead = search(Sidekiq::DeadSet.new, x)
164
+ else
165
+ @count = (params["count"] || 25).to_i
166
+ (@current_page, @total_size, @dead) = page("dead", params["page"], @count, reverse: true)
167
+ @dead = @dead.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
168
+ end
159
169
 
160
170
  erb(:morgue)
161
171
  end
@@ -174,7 +184,7 @@ module Sidekiq
174
184
  end
175
185
 
176
186
  post "/morgue" do
177
- redirect(request.path) unless params["key"]
187
+ redirect(request.path) unless url_params("key")
178
188
 
179
189
  params["key"].each do |key|
180
190
  job = Sidekiq::DeadSet.new.fetch(*parse_params(key)).first
@@ -197,7 +207,7 @@ module Sidekiq
197
207
  end
198
208
 
199
209
  post "/morgue/:key" do
200
- key = route_params[:key]
210
+ key = route_params(:key)
201
211
  halt(404) unless key
202
212
 
203
213
  job = Sidekiq::DeadSet.new.fetch(*parse_params(key)).first
@@ -207,9 +217,15 @@ module Sidekiq
207
217
  end
208
218
 
209
219
  get "/retries" do
210
- @count = (params["count"] || 25).to_i
211
- (@current_page, @total_size, @retries) = page("retry", params["page"], @count)
212
- @retries = @retries.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
220
+ x = url_params("substr")
221
+
222
+ if x && x != ""
223
+ @retries = search(Sidekiq::RetrySet.new, x)
224
+ else
225
+ @count = (params["count"] || 25).to_i
226
+ (@current_page, @total_size, @retries) = page("retry", params["page"], @count)
227
+ @retries = @retries.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
228
+ end
213
229
 
214
230
  erb(:retries)
215
231
  end
@@ -262,9 +278,15 @@ module Sidekiq
262
278
  end
263
279
 
264
280
  get "/scheduled" do
265
- @count = (params["count"] || 25).to_i
266
- (@current_page, @total_size, @scheduled) = page("schedule", params["page"], @count)
267
- @scheduled = @scheduled.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
281
+ x = params[:substr]
282
+
283
+ if x && x != ""
284
+ @scheduled = search(Sidekiq::ScheduledSet.new, x)
285
+ else
286
+ @count = (params["count"] || 25).to_i
287
+ (@current_page, @total_size, @scheduled) = page("schedule", params["page"], @count)
288
+ @scheduled = @scheduled.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
289
+ end
268
290
 
269
291
  erb(:scheduled)
270
292
  end
@@ -328,46 +350,6 @@ module Sidekiq
328
350
  json Sidekiq::Stats.new.queues
329
351
  end
330
352
 
331
- ########
332
- # Filtering
333
-
334
- route :get, :post, "/filter/metrics" do
335
- x = params[:substr]
336
- return redirect "#{root_path}metrics" unless x && x != ""
337
-
338
- q = Sidekiq::Metrics::Query.new
339
- @period = h((params[:period] || "")[0..1])
340
- @periods = METRICS_PERIODS
341
- minutes = @periods.fetch(@period, @periods.values.first)
342
- @query_result = q.top_jobs(minutes: minutes, class_filter: Regexp.new(Regexp.escape(x), Regexp::IGNORECASE))
343
-
344
- erb :metrics
345
- end
346
-
347
- route :get, :post, "/filter/retries" do
348
- x = params[:substr]
349
- return redirect "#{root_path}retries" unless x && x != ""
350
-
351
- @retries = search(Sidekiq::RetrySet.new, params[:substr])
352
- erb :retries
353
- end
354
-
355
- route :get, :post, "/filter/scheduled" do
356
- x = params[:substr]
357
- return redirect "#{root_path}scheduled" unless x && x != ""
358
-
359
- @scheduled = search(Sidekiq::ScheduledSet.new, params[:substr])
360
- erb :scheduled
361
- end
362
-
363
- route :get, :post, "/filter/dead" do
364
- x = params[:substr]
365
- return redirect "#{root_path}morgue" unless x && x != ""
366
-
367
- @dead = search(Sidekiq::DeadSet.new, params[:substr])
368
- erb :morgue
369
- end
370
-
371
353
  post "/change_locale" do
372
354
  locale = params["locale"]
373
355
 
@@ -52,11 +52,11 @@ module Sidekiq
52
52
  end
53
53
 
54
54
  def strings(lang)
55
- @strings ||= {}
55
+ @@strings ||= {}
56
56
 
57
57
  # Allow sidekiq-web extensions to add locale paths
58
58
  # so extensions can be localized
59
- @strings[lang] ||= settings.locales.each_with_object({}) do |path, global|
59
+ @@strings[lang] ||= settings.locales.each_with_object({}) do |path, global|
60
60
  find_locale_files(lang).each do |file|
61
61
  strs = YAML.safe_load(File.read(file))
62
62
  global.merge!(strs[lang])
@@ -77,19 +77,19 @@ module Sidekiq
77
77
  end
78
78
 
79
79
  def clear_caches
80
- @strings = nil
81
- @locale_files = nil
82
- @available_locales = nil
80
+ @@strings = nil
81
+ @@locale_files = nil
82
+ @@available_locales = nil
83
83
  end
84
84
 
85
85
  def locale_files
86
- @locale_files ||= settings.locales.flat_map { |path|
86
+ @@locale_files ||= settings.locales.flat_map { |path|
87
87
  Dir["#{path}/*.yml"]
88
88
  }
89
89
  end
90
90
 
91
91
  def available_locales
92
- @available_locales ||= Set.new(locale_files.map { |path| File.basename(path, ".yml") })
92
+ @@available_locales ||= Set.new(locale_files.map { |path| File.basename(path, ".yml") })
93
93
  end
94
94
 
95
95
  def find_locale_files(lang)
@@ -111,7 +111,7 @@ module Sidekiq
111
111
  if within.nil?
112
112
  ::Rack::Utils.escape_html(jid)
113
113
  else
114
- "<a href='#{root_path}filter/#{within}?substr=#{jid}'>#{::Rack::Utils.escape_html(jid)}</a>"
114
+ "<a href='#{root_path}#{within}?substr=#{jid}'>#{::Rack::Utils.escape_html(jid)}</a>"
115
115
  end
116
116
  end
117
117
 
@@ -184,7 +184,8 @@ module Sidekiq
184
184
 
185
185
  # sidekiq/sidekiq#3243
186
186
  def unfiltered?
187
- yield unless env["PATH_INFO"].start_with?("/filter/")
187
+ s = url_params("substr")
188
+ yield unless s && s.size > 0
188
189
  end
189
190
 
190
191
  def get_locale
data/lib/sidekiq/web.rb CHANGED
@@ -50,6 +50,11 @@ module Sidekiq
50
50
  end
51
51
 
52
52
  class << self
53
+ # Forward compatibility with 8.0
54
+ def configure
55
+ yield self
56
+ end
57
+
53
58
  def settings
54
59
  self
55
60
  end
data/sidekiq.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency "connection_pool", ">= 2.3.0"
28
28
  gem.add_dependency "rack", ">= 2.2.4"
29
29
  gem.add_dependency "logger"
30
+ gem.add_dependency "base64"
30
31
  end
@@ -1,6 +1,5 @@
1
1
  <div>
2
- <form method="post" class="form-inline" action='<%= root_path %>filter/<%= which %>'>
3
- <%= csrf_tag %>
2
+ <form method="get" class="form-inline" action='<%= root_path %><%= which %>'>
4
3
  <label for="substr"><%= t('Filter') %></label>
5
4
  <input class="search form-control" type="search" name="substr" value="<%= h params[:substr] %>" placeholder="<%= t('AnyJobContent') %>"/>
6
5
  </form>
@@ -9,8 +9,7 @@
9
9
  </div>
10
10
 
11
11
  <div>
12
- <form id="metrics-form" class="form-inline" action="<%= root_path %>filter/metrics" method="post">
13
- <%= csrf_tag %>
12
+ <form id="metrics-form" class="form-inline" action="<%= root_path %>metrics" method="get">
14
13
  <label for="substr"><%= t('Filter') %></label>
15
14
  <input id="class-filter" class="form-control" type="text" name="substr" placeholder="<%= t('Name') %>" value="<%= h params[:substr] %>">
16
15
  <select id="period-selector" class="form-control" name="period">
data/web/views/morgue.erb CHANGED
@@ -3,7 +3,7 @@
3
3
  <% if @dead.size > 0 && @total_size > @count %>
4
4
  <%= erb :_paging, locals: { url: "#{root_path}morgue" } %>
5
5
  <% end %>
6
- <%= filtering('dead') %>
6
+ <%= filtering('morgue') %>
7
7
  </div>
8
8
 
9
9
  <% if @dead.size > 0 %>
@@ -40,7 +40,7 @@
40
40
  </td>
41
41
  <td>
42
42
  <%= entry.display_class %>
43
- <%= display_tags(entry, "dead") %>
43
+ <%= display_tags(entry, "morgue") %>
44
44
  </td>
45
45
  <td>
46
46
  <div class="args"><%= display_args(entry.display_args) %></div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.5
4
+ version: 7.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-04 00:00:00.000000000 Z
11
+ date: 2025-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: base64
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Simple, efficient background processing for Ruby.
70
84
  email:
71
85
  - info@contribsys.com
@@ -232,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
246
  - !ruby/object:Gem::Version
233
247
  version: '0'
234
248
  requirements: []
235
- rubygems_version: 3.5.16
249
+ rubygems_version: 3.5.22
236
250
  signing_key:
237
251
  specification_version: 4
238
252
  summary: Simple, efficient background processing for Ruby