sidekiq 8.0.2 → 8.0.3
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 +7 -0
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +93 -57
- data/lib/sidekiq/profiler.rb +16 -3
- data/lib/sidekiq/rails.rb +43 -65
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/action.rb +19 -0
- data/lib/sidekiq.rb +1 -1
- data/web/assets/stylesheets/style.css +7 -0
- data/web/locales/it.yml +7 -0
- data/web/views/layout.erb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5862bbba5b859c1983788b6aeb49193fad724a1186426084c1e42747cb226ba2
|
4
|
+
data.tar.gz: 11fbaba14b814b87d09d809173ca59f9477c119f9ab6d556e4a9baa8e4e83d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d640ff21778c036ba15db434bafe0582a61e1b462d1bee2502fa7a9b8978208b4099c46d8ad6bd6214f198558de8985deeb11b6e7d99f1e603b15f087f0215
|
7
|
+
data.tar.gz: 4becc4ea36c062f52667fea91d4f49b5bfb759fe43f75ef6427c1aeacdc36764408f442cafccc3595585cf13ef2ff71da98212d7db0fcb89ff198ace0cd19caa
|
data/Changes.md
CHANGED
@@ -2,6 +2,13 @@
|
|
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
|
+
HEAD
|
6
|
+
----------
|
7
|
+
|
8
|
+
- Configure Vernier output directory [#6674]
|
9
|
+
- Rework Rails integration [#6669]
|
10
|
+
- Implement flash messages for the Web UI [#6675]
|
11
|
+
|
5
12
|
8.0.2
|
6
13
|
----------
|
7
14
|
|
@@ -1,75 +1,111 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
remove_const(:SidekiqAdapter) if const_defined?(:SidekiqAdapter)
|
3
|
+
begin
|
4
|
+
gem "activejob", ">= 7.0"
|
5
|
+
require "active_job"
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
# To use Sidekiq set the queue_adapter config to +:sidekiq+.
|
11
|
-
#
|
12
|
-
# Rails.application.config.active_job.queue_adapter = :sidekiq
|
13
|
-
class SidekiqAdapter
|
14
|
-
# Defines whether enqueuing should happen implicitly to after commit when called
|
15
|
-
# from inside a transaction.
|
7
|
+
module Sidekiq
|
8
|
+
module ActiveJob
|
16
9
|
# @api private
|
17
|
-
|
18
|
-
|
19
|
-
end
|
10
|
+
class Wrapper
|
11
|
+
include Sidekiq::Job
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
wrapped: job.class,
|
25
|
-
queue: job.queue_name
|
26
|
-
).perform_async(job.serialize)
|
13
|
+
def perform(job_data)
|
14
|
+
::ActiveJob::Base.execute(job_data.merge("provider_job_id" => jid))
|
15
|
+
end
|
27
16
|
end
|
17
|
+
end
|
18
|
+
end
|
28
19
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
20
|
+
unless ActiveJob::Base.respond_to?(:sidekiq_options)
|
21
|
+
# By including the Options module, we allow AJs to directly control sidekiq features
|
22
|
+
# via the *sidekiq_options* class method and, for instance, not use AJ's retry system.
|
23
|
+
# AJ retries don't show up in the Sidekiq UI Retries tab, don't save any error data, can't be
|
24
|
+
# manually retried, don't automatically die, etc.
|
25
|
+
#
|
26
|
+
# class SomeJob < ActiveJob::Base
|
27
|
+
# queue_as :default
|
28
|
+
# sidekiq_options retry: 3, backtrace: 10
|
29
|
+
# def perform
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
ActiveJob::Base.include Sidekiq::Job::Options
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
immediate_jobs, scheduled_jobs = same_class_and_queue_jobs.partition { |job| job.scheduled_at.nil? }
|
35
|
+
# Patch the ActiveJob module
|
36
|
+
module ActiveJob
|
37
|
+
module QueueAdapters
|
38
|
+
# Explicitly remove the implementation existing in older Rails.
|
39
|
+
remove_const(:SidekiqAdapter) if const_defined?(:SidekiqAdapter)
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
# Sidekiq adapter for Active Job
|
42
|
+
#
|
43
|
+
# To use Sidekiq set the queue_adapter config to +:sidekiq+.
|
44
|
+
#
|
45
|
+
# Rails.application.config.active_job.queue_adapter = :sidekiq
|
46
|
+
class SidekiqAdapter
|
47
|
+
# Defines whether enqueuing should happen implicitly to after commit when called
|
48
|
+
# from inside a transaction.
|
49
|
+
# @api private
|
50
|
+
def enqueue_after_transaction_commit?
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
# @api private
|
55
|
+
def enqueue(job)
|
56
|
+
job.provider_job_id = Sidekiq::ActiveJob::Wrapper.set(
|
57
|
+
wrapped: job.class,
|
58
|
+
queue: job.queue_name
|
59
|
+
).perform_async(job.serialize)
|
60
|
+
end
|
61
|
+
|
62
|
+
# @api private
|
63
|
+
def enqueue_at(job, timestamp)
|
64
|
+
job.provider_job_id = Sidekiq::ActiveJob::Wrapper.set(
|
65
|
+
wrapped: job.class,
|
66
|
+
queue: job.queue_name
|
67
|
+
).perform_at(timestamp, job.serialize)
|
68
|
+
end
|
53
69
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
70
|
+
# @api private
|
71
|
+
def enqueue_all(jobs)
|
72
|
+
enqueued_count = 0
|
73
|
+
jobs.group_by(&:class).each do |job_class, same_class_jobs|
|
74
|
+
same_class_jobs.group_by(&:queue_name).each do |queue, same_class_and_queue_jobs|
|
75
|
+
immediate_jobs, scheduled_jobs = same_class_and_queue_jobs.partition { |job| job.scheduled_at.nil? }
|
76
|
+
|
77
|
+
if immediate_jobs.any?
|
78
|
+
jids = Sidekiq::Client.push_bulk(
|
79
|
+
"class" => Sidekiq::ActiveJob::Wrapper,
|
80
|
+
"wrapped" => job_class,
|
81
|
+
"queue" => queue,
|
82
|
+
"args" => immediate_jobs.map { |job| [job.serialize] }
|
83
|
+
)
|
84
|
+
enqueued_count += jids.compact.size
|
85
|
+
end
|
86
|
+
|
87
|
+
if scheduled_jobs.any?
|
88
|
+
jids = Sidekiq::Client.push_bulk(
|
89
|
+
"class" => Sidekiq::ActiveJob::Wrapper,
|
90
|
+
"wrapped" => job_class,
|
91
|
+
"queue" => queue,
|
92
|
+
"args" => scheduled_jobs.map { |job| [job.serialize] },
|
93
|
+
"at" => scheduled_jobs.map { |job| job.scheduled_at&.to_f }
|
94
|
+
)
|
95
|
+
enqueued_count += jids.compact.size
|
96
|
+
end
|
63
97
|
end
|
64
98
|
end
|
99
|
+
enqueued_count
|
65
100
|
end
|
66
|
-
enqueued_count
|
67
|
-
end
|
68
101
|
|
69
|
-
|
70
|
-
|
71
|
-
|
102
|
+
# Defines a class alias for backwards compatibility with enqueued Active Job jobs.
|
103
|
+
# @api private
|
104
|
+
class JobWrapper < Sidekiq::ActiveJob::Wrapper
|
105
|
+
end
|
72
106
|
end
|
73
107
|
end
|
74
108
|
end
|
109
|
+
rescue Gem::LoadError
|
110
|
+
# ActiveJob not available or version requirement not met
|
75
111
|
end
|
data/lib/sidekiq/profiler.rb
CHANGED
@@ -13,6 +13,7 @@ module Sidekiq
|
|
13
13
|
include Sidekiq::Component
|
14
14
|
def initialize(config)
|
15
15
|
@config = config
|
16
|
+
@vernier_output_dir = ENV.fetch("VERNIER_OUTPUT_DIR") { Dir.tmpdir }
|
16
17
|
end
|
17
18
|
|
18
19
|
def call(job, &block)
|
@@ -22,7 +23,6 @@ module Sidekiq
|
|
22
23
|
type = job["class"]
|
23
24
|
jid = job["jid"]
|
24
25
|
started_at = Time.now
|
25
|
-
options = DEFAULT_OPTIONS.merge((job["profiler_options"] || {}).transform_keys!(&:to_sym))
|
26
26
|
|
27
27
|
rundata = {
|
28
28
|
started_at: started_at.to_i,
|
@@ -30,13 +30,17 @@ module Sidekiq
|
|
30
30
|
type: type,
|
31
31
|
jid: jid,
|
32
32
|
# .gz extension tells Vernier to compress the data
|
33
|
-
filename:
|
33
|
+
filename: File.join(
|
34
|
+
@vernier_output_dir,
|
35
|
+
"#{token}-#{type}-#{jid}-#{started_at.strftime("%Y%m%d-%H%M%S")}.json.gz"
|
36
|
+
)
|
34
37
|
}
|
38
|
+
profiler_options = profiler_options(job, rundata)
|
35
39
|
|
36
40
|
require "vernier"
|
37
41
|
begin
|
38
42
|
a = Time.now
|
39
|
-
rc = Vernier.profile(**
|
43
|
+
rc = Vernier.profile(**profiler_options, &block)
|
40
44
|
b = Time.now
|
41
45
|
|
42
46
|
# Failed jobs will raise an exception on previous line and skip this
|
@@ -55,5 +59,14 @@ module Sidekiq
|
|
55
59
|
FileUtils.rm_f(rundata[:filename])
|
56
60
|
end
|
57
61
|
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def profiler_options(job, rundata)
|
66
|
+
profiler_options = (job["profiler_options"] || {}).transform_keys(&:to_sym)
|
67
|
+
profiler_options[:mode] = profiler_options[:mode].to_sym if profiler_options[:mode]
|
68
|
+
|
69
|
+
DEFAULT_OPTIONS.merge(profiler_options, {out: rundata[:filename]})
|
70
|
+
end
|
58
71
|
end
|
59
72
|
end
|
data/lib/sidekiq/rails.rb
CHANGED
@@ -1,84 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "sidekiq/job"
|
4
|
-
|
4
|
+
require_relative "../active_job/queue_adapters/sidekiq_adapter"
|
5
5
|
|
6
6
|
module Sidekiq
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Rails < ::Rails::Engine
|
19
|
-
class Reloader
|
20
|
-
def initialize(app = ::Rails.application)
|
21
|
-
@app = app
|
22
|
-
end
|
23
|
-
|
24
|
-
def call
|
25
|
-
params = (::Rails::VERSION::STRING >= "7.1") ? {source: "job.sidekiq"} : {}
|
26
|
-
@app.reloader.wrap(**params) do
|
27
|
-
yield
|
7
|
+
begin
|
8
|
+
gem "railties", ">= 7.0"
|
9
|
+
require "rails"
|
10
|
+
|
11
|
+
class Rails < ::Rails::Engine
|
12
|
+
class Reloader
|
13
|
+
def initialize(app = ::Rails.application)
|
14
|
+
@app = app
|
28
15
|
end
|
29
|
-
end
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
def call
|
18
|
+
params = (::Rails::VERSION::STRING >= "7.1") ? {source: "job.sidekiq"} : {}
|
19
|
+
@app.reloader.wrap(**params) do
|
20
|
+
yield
|
21
|
+
end
|
22
|
+
end
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
24
|
+
def inspect
|
25
|
+
"#<Sidekiq::Rails::Reloader @app=#{@app.class.name}>"
|
26
|
+
end
|
39
27
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# manually retried, don't automatically die, etc.
|
44
|
-
#
|
45
|
-
# class SomeJob < ActiveJob::Base
|
46
|
-
# queue_as :default
|
47
|
-
# sidekiq_options retry: 3, backtrace: 10
|
48
|
-
# def perform
|
49
|
-
# end
|
50
|
-
# end
|
51
|
-
initializer "sidekiq.active_job_integration" do
|
52
|
-
ActiveSupport.on_load(:active_job) do
|
53
|
-
require_relative "../active_job/queue_adapters/sidekiq_adapter"
|
54
|
-
include ::Sidekiq::Job::Options unless respond_to?(:sidekiq_options)
|
28
|
+
def to_hash
|
29
|
+
{app: @app.class.name}
|
30
|
+
end
|
55
31
|
end
|
56
|
-
end
|
57
32
|
|
58
|
-
|
59
|
-
|
60
|
-
|
33
|
+
initializer "sidekiq.backtrace_cleaner" do
|
34
|
+
Sidekiq.configure_server do |config|
|
35
|
+
config[:backtrace_cleaner] = ->(backtrace) { ::Rails.backtrace_cleaner.clean(backtrace) }
|
36
|
+
end
|
61
37
|
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# This hook happens after all initializers are run, just before returning
|
65
|
-
# from config/environment.rb back to sidekiq/cli.rb.
|
66
|
-
#
|
67
|
-
# None of this matters on the client-side, only within the Sidekiq process itself.
|
68
|
-
config.after_initialize do
|
69
|
-
Sidekiq.configure_server do |config|
|
70
|
-
config[:reloader] = Sidekiq::Rails::Reloader.new
|
71
38
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
39
|
+
# This hook happens after all initializers are run, just before returning
|
40
|
+
# from config/environment.rb back to sidekiq/cli.rb.
|
41
|
+
#
|
42
|
+
# None of this matters on the client-side, only within the Sidekiq process itself.
|
43
|
+
config.after_initialize do
|
44
|
+
Sidekiq.configure_server do |config|
|
45
|
+
config[:reloader] = Sidekiq::Rails::Reloader.new
|
46
|
+
|
47
|
+
# This is the integration code necessary so that if a job uses `Rails.logger.info "Hello"`,
|
48
|
+
# it will appear in the Sidekiq console with all of the job context.
|
49
|
+
unless ::Rails.logger == config.logger || ::ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, $stdout)
|
50
|
+
if ::Rails.logger.respond_to?(:broadcast_to)
|
51
|
+
::Rails.logger.broadcast_to(config.logger)
|
52
|
+
else
|
53
|
+
::Rails.logger.extend(::ActiveSupport::Logger.broadcast(config.logger))
|
54
|
+
end
|
79
55
|
end
|
80
56
|
end
|
81
57
|
end
|
82
58
|
end
|
59
|
+
rescue Gem::LoadError
|
60
|
+
# Rails not available or version requirement not met
|
83
61
|
end
|
84
62
|
end
|
data/lib/sidekiq/version.rb
CHANGED
data/lib/sidekiq/web/action.rb
CHANGED
@@ -70,6 +70,25 @@ module Sidekiq
|
|
70
70
|
env["rack.session"]
|
71
71
|
end
|
72
72
|
|
73
|
+
def logger
|
74
|
+
Sidekiq.logger
|
75
|
+
end
|
76
|
+
|
77
|
+
# flash { "Some message to show on redirect" }
|
78
|
+
def flash
|
79
|
+
msg = yield
|
80
|
+
logger.info msg
|
81
|
+
session[:flash] = msg
|
82
|
+
end
|
83
|
+
|
84
|
+
def flash?
|
85
|
+
session&.[](:flash)
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_flash
|
89
|
+
@flash ||= session.delete(:flash)
|
90
|
+
end
|
91
|
+
|
73
92
|
def erb(content, options = {})
|
74
93
|
if content.is_a? Symbol
|
75
94
|
unless respond_to?(:"_erb_#{content}")
|
data/lib/sidekiq.rb
CHANGED
data/web/locales/it.yml
CHANGED
@@ -35,6 +35,7 @@ it:
|
|
35
35
|
Jobs: Lavori
|
36
36
|
Kill: Uccidere
|
37
37
|
KillAll: Uccidere tutti
|
38
|
+
Language: Lingua
|
38
39
|
LastRetry: Ultimo tentativo
|
39
40
|
Latency: Latenza
|
40
41
|
LivePoll: Live poll
|
@@ -54,6 +55,7 @@ it:
|
|
54
55
|
PeakMemoryUsage: Memoria utilizzata (max.)
|
55
56
|
Plugins: Plugins
|
56
57
|
PollingInterval: Intervallo di polling
|
58
|
+
PollingIntervalMilliseconds: Intervallo di polling in millisecondi
|
57
59
|
Process: Processo
|
58
60
|
Processed: Processato
|
59
61
|
Processes: Processi
|
@@ -99,3 +101,8 @@ it:
|
|
99
101
|
NoJobMetricsFound: Metriche recenti di lavoro non trovate
|
100
102
|
Filter: Filtro
|
101
103
|
AnyJobContent: Qualsiasi contenuto di lavoro
|
104
|
+
Profiles: Profili
|
105
|
+
Data: Dati
|
106
|
+
View: Vista
|
107
|
+
Token: Token
|
108
|
+
ElapsedTime: Tempo Trascorso
|
data/web/views/layout.erb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-24 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: redis-client
|