sidekiq 6.5.6 → 7.0.0.beta1
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 +4 -4
- data/Changes.md +16 -4
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.md +13 -12
- data/bin/sidekiq +3 -8
- data/bin/sidekiqload +15 -24
- data/lib/sidekiq/api.rb +55 -111
- data/lib/sidekiq/capsule.rb +110 -0
- data/lib/sidekiq/cli.rb +44 -47
- data/lib/sidekiq/client.rb +29 -16
- data/lib/sidekiq/component.rb +1 -0
- data/lib/sidekiq/config.rb +270 -0
- data/lib/sidekiq/deploy.rb +62 -0
- data/lib/sidekiq/embedded.rb +61 -0
- data/lib/sidekiq/fetch.rb +10 -11
- data/lib/sidekiq/job.rb +375 -10
- data/lib/sidekiq/job_logger.rb +1 -1
- data/lib/sidekiq/job_retry.rb +8 -8
- data/lib/sidekiq/job_util.rb +4 -4
- data/lib/sidekiq/launcher.rb +36 -46
- data/lib/sidekiq/logger.rb +1 -26
- data/lib/sidekiq/manager.rb +9 -11
- data/lib/sidekiq/metrics/query.rb +2 -2
- data/lib/sidekiq/metrics/shared.rb +4 -3
- data/lib/sidekiq/metrics/tracking.rb +18 -18
- data/lib/sidekiq/middleware/chain.rb +7 -9
- data/lib/sidekiq/middleware/current_attributes.rb +8 -13
- data/lib/sidekiq/pool.rb +7 -0
- data/lib/sidekiq/processor.rb +17 -26
- data/lib/sidekiq/redis_client_adapter.rb +9 -45
- data/lib/sidekiq/redis_connection.rb +11 -111
- data/lib/sidekiq/scheduled.rb +58 -25
- data/lib/sidekiq/testing.rb +4 -32
- data/lib/sidekiq/transaction_aware_client.rb +4 -5
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/application.rb +1 -1
- data/lib/sidekiq/web/csrf_protection.rb +1 -1
- data/lib/sidekiq/web/helpers.rb +5 -16
- data/lib/sidekiq/web.rb +2 -17
- data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
- data/lib/sidekiq.rb +52 -274
- data/sidekiq.gemspec +29 -5
- data/web/assets/javascripts/base-charts.js +106 -0
- data/web/assets/javascripts/dashboard-charts.js +166 -0
- data/web/assets/javascripts/dashboard.js +3 -223
- data/web/assets/javascripts/metrics.js +90 -116
- data/web/assets/stylesheets/application-rtl.css +2 -91
- data/web/assets/stylesheets/application.css +21 -296
- data/web/locales/ar.yml +70 -70
- data/web/locales/cs.yml +62 -62
- data/web/locales/da.yml +52 -52
- data/web/locales/de.yml +65 -65
- data/web/locales/el.yml +2 -7
- data/web/locales/en.yml +76 -70
- data/web/locales/es.yml +68 -68
- data/web/locales/fa.yml +65 -65
- data/web/locales/fr.yml +67 -67
- data/web/locales/he.yml +65 -64
- data/web/locales/hi.yml +59 -59
- data/web/locales/it.yml +53 -53
- data/web/locales/ja.yml +71 -68
- data/web/locales/ko.yml +52 -52
- data/web/locales/lt.yml +66 -66
- data/web/locales/nb.yml +61 -61
- data/web/locales/nl.yml +52 -52
- data/web/locales/pl.yml +45 -45
- data/web/locales/pt-br.yml +59 -69
- data/web/locales/pt.yml +51 -51
- data/web/locales/ru.yml +67 -66
- data/web/locales/sv.yml +53 -53
- data/web/locales/ta.yml +60 -60
- data/web/locales/uk.yml +62 -61
- data/web/locales/ur.yml +64 -64
- data/web/locales/vi.yml +67 -67
- data/web/locales/zh-cn.yml +37 -11
- data/web/locales/zh-tw.yml +42 -8
- data/web/views/_footer.erb +5 -2
- data/web/views/dashboard.erb +36 -5
- data/web/views/metrics.erb +30 -19
- data/web/views/metrics_for_job.erb +16 -34
- metadata +59 -30
- data/lib/sidekiq/delay.rb +0 -43
- 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/metrics/deploy.rb +0 -47
- data/lib/sidekiq/worker.rb +0 -367
- data/web/assets/javascripts/graph.js +0 -16
metadata
CHANGED
@@ -1,63 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: redis
|
14
|
+
name: redis-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "<"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: 0.9.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "<"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '5'
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: 0.9.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: connection_pool
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2.
|
33
|
+
version: 2.3.0
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.
|
40
|
+
version: 2.3.0
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rack
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- - "
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.2.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.2.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: concurrent-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
52
60
|
- !ruby/object:Gem::Version
|
53
|
-
version: '2
|
61
|
+
version: '2'
|
54
62
|
type: :runtime
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
65
|
requirements:
|
58
|
-
- - "
|
66
|
+
- - "<"
|
59
67
|
- !ruby/object:Gem::Version
|
60
|
-
version: '2
|
68
|
+
version: '2'
|
61
69
|
description: Simple, efficient background processing for Ruby.
|
62
70
|
email:
|
63
71
|
- mperham@gmail.com
|
@@ -68,7 +76,7 @@ extensions: []
|
|
68
76
|
extra_rdoc_files: []
|
69
77
|
files:
|
70
78
|
- Changes.md
|
71
|
-
- LICENSE
|
79
|
+
- LICENSE.txt
|
72
80
|
- README.md
|
73
81
|
- bin/sidekiq
|
74
82
|
- bin/sidekiqload
|
@@ -79,14 +87,13 @@ files:
|
|
79
87
|
- lib/generators/sidekiq/templates/job_test.rb.erb
|
80
88
|
- lib/sidekiq.rb
|
81
89
|
- lib/sidekiq/api.rb
|
90
|
+
- lib/sidekiq/capsule.rb
|
82
91
|
- lib/sidekiq/cli.rb
|
83
92
|
- lib/sidekiq/client.rb
|
84
93
|
- lib/sidekiq/component.rb
|
85
|
-
- lib/sidekiq/
|
86
|
-
- lib/sidekiq/
|
87
|
-
- lib/sidekiq/
|
88
|
-
- lib/sidekiq/extensions/class_methods.rb
|
89
|
-
- lib/sidekiq/extensions/generic_proxy.rb
|
94
|
+
- lib/sidekiq/config.rb
|
95
|
+
- lib/sidekiq/deploy.rb
|
96
|
+
- lib/sidekiq/embedded.rb
|
90
97
|
- lib/sidekiq/fetch.rb
|
91
98
|
- lib/sidekiq/job.rb
|
92
99
|
- lib/sidekiq/job_logger.rb
|
@@ -95,7 +102,6 @@ files:
|
|
95
102
|
- lib/sidekiq/launcher.rb
|
96
103
|
- lib/sidekiq/logger.rb
|
97
104
|
- lib/sidekiq/manager.rb
|
98
|
-
- lib/sidekiq/metrics/deploy.rb
|
99
105
|
- lib/sidekiq/metrics/query.rb
|
100
106
|
- lib/sidekiq/metrics/shared.rb
|
101
107
|
- lib/sidekiq/metrics/tracking.rb
|
@@ -105,6 +111,7 @@ files:
|
|
105
111
|
- lib/sidekiq/middleware/modules.rb
|
106
112
|
- lib/sidekiq/monitor.rb
|
107
113
|
- lib/sidekiq/paginator.rb
|
114
|
+
- lib/sidekiq/pool.rb
|
108
115
|
- lib/sidekiq/processor.rb
|
109
116
|
- lib/sidekiq/rails.rb
|
110
117
|
- lib/sidekiq/redis_client_adapter.rb
|
@@ -123,17 +130,18 @@ files:
|
|
123
130
|
- lib/sidekiq/web/csrf_protection.rb
|
124
131
|
- lib/sidekiq/web/helpers.rb
|
125
132
|
- lib/sidekiq/web/router.rb
|
126
|
-
- lib/sidekiq/
|
133
|
+
- lib/sidekiq/worker_compatibility_alias.rb
|
127
134
|
- sidekiq.gemspec
|
128
135
|
- web/assets/images/apple-touch-icon.png
|
129
136
|
- web/assets/images/favicon.ico
|
130
137
|
- web/assets/images/logo.png
|
131
138
|
- web/assets/images/status.png
|
132
139
|
- web/assets/javascripts/application.js
|
140
|
+
- web/assets/javascripts/base-charts.js
|
133
141
|
- web/assets/javascripts/chart.min.js
|
134
142
|
- web/assets/javascripts/chartjs-plugin-annotation.min.js
|
143
|
+
- web/assets/javascripts/dashboard-charts.js
|
135
144
|
- web/assets/javascripts/dashboard.js
|
136
|
-
- web/assets/javascripts/graph.js
|
137
145
|
- web/assets/javascripts/metrics.js
|
138
146
|
- web/assets/stylesheets/application-dark.css
|
139
147
|
- web/assets/stylesheets/application-rtl.css
|
@@ -197,7 +205,28 @@ metadata:
|
|
197
205
|
documentation_uri: https://github.com/mperham/sidekiq/wiki
|
198
206
|
changelog_uri: https://github.com/mperham/sidekiq/blob/main/Changes.md
|
199
207
|
source_code_uri: https://github.com/mperham/sidekiq
|
200
|
-
post_install_message:
|
208
|
+
post_install_message: |2
|
209
|
+
|
210
|
+
####################################################
|
211
|
+
|
212
|
+
|
213
|
+
█████████ █████ ██████████ ██████████ █████ ████ █████ ██████ ██████████ █████
|
214
|
+
███░░░░░███░░███ ░░███░░░░███ ░░███░░░░░█░░███ ███░ ░░███ ███░░░░███ ░███░░░░███ ███░░░███
|
215
|
+
░███ ░░░ ░███ ░███ ░░███ ░███ █ ░ ░███ ███ ░███ ███ ░░███ ░░░ ███ ███ ░░███
|
216
|
+
░░█████████ ░███ ░███ ░███ ░██████ ░███████ ░███ ░███ ░███ ███ ░███ ░███
|
217
|
+
░░░░░░░░███ ░███ ░███ ░███ ░███░░█ ░███░░███ ░███ ░███ ██░███ ███ ░███ ░███
|
218
|
+
███ ░███ ░███ ░███ ███ ░███ ░ █ ░███ ░░███ ░███ ░░███ ░░████ ███ ░░███ ███
|
219
|
+
░░█████████ █████ ██████████ ██████████ █████ ░░████ █████ ░░░██████░██ ███ ██ ░░░█████░
|
220
|
+
░░░░░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░░ ░░ ░░░ ░░ ░░░░░░
|
221
|
+
|
222
|
+
|
223
|
+
WARNING: This is a beta release, expect breakage!
|
224
|
+
|
225
|
+
1. Use `gem 'sidekiq', '<7'` in your Gemfile if you don't want to be a beta tester.
|
226
|
+
2. Read the release notes at https://github.com/mperham/sidekiq/blob/7-0/docs/7.0-Upgrade.md
|
227
|
+
3. Search for open/closed issues at https://github.com/mperham/sidekiq/issues/
|
228
|
+
|
229
|
+
####################################################
|
201
230
|
rdoc_options: []
|
202
231
|
require_paths:
|
203
232
|
- lib
|
@@ -205,12 +234,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
234
|
requirements:
|
206
235
|
- - ">="
|
207
236
|
- !ruby/object:Gem::Version
|
208
|
-
version: 2.
|
237
|
+
version: 2.7.0
|
209
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
239
|
requirements:
|
211
|
-
- - "
|
240
|
+
- - ">"
|
212
241
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
242
|
+
version: 1.3.1
|
214
243
|
requirements: []
|
215
244
|
rubygems_version: 3.2.32
|
216
245
|
signing_key:
|
data/lib/sidekiq/delay.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sidekiq # :nodoc:
|
4
|
-
module Extensions
|
5
|
-
def self.enable_delay!
|
6
|
-
warn "Sidekiq's Delayed Extensions will be removed in Sidekiq 7.0", uplevel: 1
|
7
|
-
|
8
|
-
if defined?(::ActiveSupport)
|
9
|
-
require "sidekiq/extensions/active_record"
|
10
|
-
require "sidekiq/extensions/action_mailer"
|
11
|
-
|
12
|
-
# Need to patch Psych so it can autoload classes whose names are serialized
|
13
|
-
# in the delayed YAML.
|
14
|
-
Psych::Visitors::ToRuby.prepend(Sidekiq::Extensions::PsychAutoload)
|
15
|
-
|
16
|
-
ActiveSupport.on_load(:active_record) do
|
17
|
-
include Sidekiq::Extensions::ActiveRecord
|
18
|
-
end
|
19
|
-
ActiveSupport.on_load(:action_mailer) do
|
20
|
-
extend Sidekiq::Extensions::ActionMailer
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require "sidekiq/extensions/class_methods"
|
25
|
-
Module.__send__(:include, Sidekiq::Extensions::Klass)
|
26
|
-
end
|
27
|
-
|
28
|
-
module PsychAutoload
|
29
|
-
def resolve_class(klass_name)
|
30
|
-
return nil if !klass_name || klass_name.empty?
|
31
|
-
# constantize
|
32
|
-
names = klass_name.split("::")
|
33
|
-
names.shift if names.empty? || names.first.empty?
|
34
|
-
|
35
|
-
names.inject(Object) do |constant, name|
|
36
|
-
constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
37
|
-
end
|
38
|
-
rescue NameError
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "sidekiq/extensions/generic_proxy"
|
4
|
-
|
5
|
-
module Sidekiq
|
6
|
-
module Extensions
|
7
|
-
##
|
8
|
-
# Adds +delay+, +delay_for+ and +delay_until+ methods to ActionMailer to offload arbitrary email
|
9
|
-
# delivery to Sidekiq.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# UserMailer.delay.send_welcome_email(new_user)
|
13
|
-
# UserMailer.delay_for(5.days).send_welcome_email(new_user)
|
14
|
-
# UserMailer.delay_until(5.days.from_now).send_welcome_email(new_user)
|
15
|
-
class DelayedMailer
|
16
|
-
include Sidekiq::Worker
|
17
|
-
|
18
|
-
def perform(yml)
|
19
|
-
(target, method_name, args) = YAML.load(yml)
|
20
|
-
msg = target.public_send(method_name, *args)
|
21
|
-
# The email method can return nil, which causes ActionMailer to return
|
22
|
-
# an undeliverable empty message.
|
23
|
-
if msg
|
24
|
-
msg.deliver_now
|
25
|
-
else
|
26
|
-
raise "#{target.name}##{method_name} returned an undeliverable mail object"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module ActionMailer
|
32
|
-
def sidekiq_delay(options = {})
|
33
|
-
Proxy.new(DelayedMailer, self, options)
|
34
|
-
end
|
35
|
-
|
36
|
-
def sidekiq_delay_for(interval, options = {})
|
37
|
-
Proxy.new(DelayedMailer, self, options.merge("at" => Time.now.to_f + interval.to_f))
|
38
|
-
end
|
39
|
-
|
40
|
-
def sidekiq_delay_until(timestamp, options = {})
|
41
|
-
Proxy.new(DelayedMailer, self, options.merge("at" => timestamp.to_f))
|
42
|
-
end
|
43
|
-
alias_method :delay, :sidekiq_delay
|
44
|
-
alias_method :delay_for, :sidekiq_delay_for
|
45
|
-
alias_method :delay_until, :sidekiq_delay_until
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "sidekiq/extensions/generic_proxy"
|
4
|
-
|
5
|
-
module Sidekiq
|
6
|
-
module Extensions
|
7
|
-
##
|
8
|
-
# Adds +delay+, +delay_for+ and +delay_until+ methods to ActiveRecord to offload instance method
|
9
|
-
# execution to Sidekiq.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# User.recent_signups.each { |user| user.delay.mark_as_awesome }
|
13
|
-
#
|
14
|
-
# Please note, this is not recommended as this will serialize the entire
|
15
|
-
# object to Redis. Your Sidekiq jobs should pass IDs, not entire instances.
|
16
|
-
# This is here for backwards compatibility with Delayed::Job only.
|
17
|
-
class DelayedModel
|
18
|
-
include Sidekiq::Worker
|
19
|
-
|
20
|
-
def perform(yml)
|
21
|
-
(target, method_name, args) = YAML.load(yml)
|
22
|
-
target.__send__(method_name, *args)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
module ActiveRecord
|
27
|
-
def sidekiq_delay(options = {})
|
28
|
-
Proxy.new(DelayedModel, self, options)
|
29
|
-
end
|
30
|
-
|
31
|
-
def sidekiq_delay_for(interval, options = {})
|
32
|
-
Proxy.new(DelayedModel, self, options.merge("at" => Time.now.to_f + interval.to_f))
|
33
|
-
end
|
34
|
-
|
35
|
-
def sidekiq_delay_until(timestamp, options = {})
|
36
|
-
Proxy.new(DelayedModel, self, options.merge("at" => timestamp.to_f))
|
37
|
-
end
|
38
|
-
alias_method :delay, :sidekiq_delay
|
39
|
-
alias_method :delay_for, :sidekiq_delay_for
|
40
|
-
alias_method :delay_until, :sidekiq_delay_until
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "sidekiq/extensions/generic_proxy"
|
4
|
-
|
5
|
-
module Sidekiq
|
6
|
-
module Extensions
|
7
|
-
##
|
8
|
-
# Adds `delay`, `delay_for` and `delay_until` methods to all Classes to offload class method
|
9
|
-
# execution to Sidekiq.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# User.delay.delete_inactive
|
13
|
-
# Wikipedia.delay.download_changes_for(Date.today)
|
14
|
-
#
|
15
|
-
class DelayedClass
|
16
|
-
include Sidekiq::Worker
|
17
|
-
|
18
|
-
def perform(yml)
|
19
|
-
(target, method_name, args) = YAML.load(yml)
|
20
|
-
target.__send__(method_name, *args)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module Klass
|
25
|
-
def sidekiq_delay(options = {})
|
26
|
-
Proxy.new(DelayedClass, self, options)
|
27
|
-
end
|
28
|
-
|
29
|
-
def sidekiq_delay_for(interval, options = {})
|
30
|
-
Proxy.new(DelayedClass, self, options.merge("at" => Time.now.to_f + interval.to_f))
|
31
|
-
end
|
32
|
-
|
33
|
-
def sidekiq_delay_until(timestamp, options = {})
|
34
|
-
Proxy.new(DelayedClass, self, options.merge("at" => timestamp.to_f))
|
35
|
-
end
|
36
|
-
alias_method :delay, :sidekiq_delay
|
37
|
-
alias_method :delay_for, :sidekiq_delay_for
|
38
|
-
alias_method :delay_until, :sidekiq_delay_until
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Module.__send__(:include, Sidekiq::Extensions::Klass) unless defined?(::Rails)
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "yaml"
|
4
|
-
|
5
|
-
module Sidekiq
|
6
|
-
module Extensions
|
7
|
-
SIZE_LIMIT = 8_192
|
8
|
-
|
9
|
-
class Proxy < BasicObject
|
10
|
-
def initialize(performable, target, options = {})
|
11
|
-
@performable = performable
|
12
|
-
@target = target
|
13
|
-
@opts = options.transform_keys(&:to_s)
|
14
|
-
end
|
15
|
-
|
16
|
-
def method_missing(name, *args)
|
17
|
-
# Sidekiq has a limitation in that its message must be JSON.
|
18
|
-
# JSON can't round trip real Ruby objects so we use YAML to
|
19
|
-
# serialize the objects to a String. The YAML will be converted
|
20
|
-
# to JSON and then deserialized on the other side back into a
|
21
|
-
# Ruby object.
|
22
|
-
obj = [@target, name, args]
|
23
|
-
marshalled = ::YAML.dump(obj)
|
24
|
-
if marshalled.size > SIZE_LIMIT
|
25
|
-
::Sidekiq.logger.warn { "#{@target}.#{name} job argument is #{marshalled.bytesize} bytes, you should refactor it to reduce the size" }
|
26
|
-
end
|
27
|
-
@performable.client_push({"class" => @performable,
|
28
|
-
"args" => [marshalled],
|
29
|
-
"display_class" => "#{@target}.#{name}"}.merge(@opts))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require "sidekiq"
|
2
|
-
require "time"
|
3
|
-
|
4
|
-
# This file is designed to be required within the user's
|
5
|
-
# deployment script; it should need a bare minimum of dependencies.
|
6
|
-
#
|
7
|
-
# require "sidekiq/metrics/deploy"
|
8
|
-
# gitdesc = `git log -1 --format="%h %s"`.strip
|
9
|
-
# d = Sidekiq::Metrics::Deploy.new
|
10
|
-
# d.mark(label: gitdesc)
|
11
|
-
#
|
12
|
-
# Note that you cannot mark more than once per minute. This is a feature, not a bug.
|
13
|
-
module Sidekiq
|
14
|
-
module Metrics
|
15
|
-
class Deploy
|
16
|
-
MARK_TTL = 90 * 24 * 60 * 60 # 90 days
|
17
|
-
|
18
|
-
def initialize(pool = Sidekiq.redis_pool)
|
19
|
-
@pool = pool
|
20
|
-
end
|
21
|
-
|
22
|
-
def mark(at: Time.now, label: "")
|
23
|
-
# we need to round the timestamp so that we gracefully
|
24
|
-
# handle an excepted common error in marking deploys:
|
25
|
-
# having every process mark its deploy, leading
|
26
|
-
# to N marks for each deploy. Instead we round the time
|
27
|
-
# to the minute so that multple marks within that minute
|
28
|
-
# will all naturally rollup into one mark per minute.
|
29
|
-
whence = at.utc
|
30
|
-
floor = Time.utc(whence.year, whence.month, whence.mday, whence.hour, whence.min, 0)
|
31
|
-
datecode = floor.strftime("%Y%m%d")
|
32
|
-
key = "#{datecode}-marks"
|
33
|
-
@pool.with do |c|
|
34
|
-
c.pipelined do |pipe|
|
35
|
-
pipe.hsetnx(key, floor.iso8601, label)
|
36
|
-
pipe.expire(key, MARK_TTL)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def fetch(date = Time.now.utc.to_date)
|
42
|
-
datecode = date.strftime("%Y%m%d")
|
43
|
-
@pool.with { |c| c.hgetall("#{datecode}-marks") }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|