sidekiq 6.2.2 → 7.1.2

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.

Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +299 -11
  3. data/LICENSE.txt +9 -0
  4. data/README.md +45 -32
  5. data/bin/sidekiq +4 -9
  6. data/bin/sidekiqload +207 -117
  7. data/bin/sidekiqmon +4 -1
  8. data/lib/generators/sidekiq/job_generator.rb +57 -0
  9. data/lib/generators/sidekiq/templates/{worker.rb.erb → job.rb.erb} +2 -2
  10. data/lib/generators/sidekiq/templates/{worker_spec.rb.erb → job_spec.rb.erb} +1 -1
  11. data/lib/generators/sidekiq/templates/{worker_test.rb.erb → job_test.rb.erb} +1 -1
  12. data/lib/sidekiq/api.rb +334 -190
  13. data/lib/sidekiq/capsule.rb +127 -0
  14. data/lib/sidekiq/cli.rb +95 -81
  15. data/lib/sidekiq/client.rb +102 -96
  16. data/lib/sidekiq/{util.rb → component.rb} +14 -41
  17. data/lib/sidekiq/config.rb +278 -0
  18. data/lib/sidekiq/deploy.rb +62 -0
  19. data/lib/sidekiq/embedded.rb +61 -0
  20. data/lib/sidekiq/fetch.rb +26 -26
  21. data/lib/sidekiq/job.rb +371 -5
  22. data/lib/sidekiq/job_logger.rb +16 -28
  23. data/lib/sidekiq/job_retry.rb +85 -59
  24. data/lib/sidekiq/job_util.rb +105 -0
  25. data/lib/sidekiq/launcher.rb +106 -94
  26. data/lib/sidekiq/logger.rb +9 -44
  27. data/lib/sidekiq/manager.rb +40 -41
  28. data/lib/sidekiq/metrics/query.rb +153 -0
  29. data/lib/sidekiq/metrics/shared.rb +95 -0
  30. data/lib/sidekiq/metrics/tracking.rb +136 -0
  31. data/lib/sidekiq/middleware/chain.rb +96 -51
  32. data/lib/sidekiq/middleware/current_attributes.rb +95 -0
  33. data/lib/sidekiq/middleware/i18n.rb +6 -4
  34. data/lib/sidekiq/middleware/modules.rb +21 -0
  35. data/lib/sidekiq/monitor.rb +17 -4
  36. data/lib/sidekiq/paginator.rb +17 -9
  37. data/lib/sidekiq/processor.rb +60 -60
  38. data/lib/sidekiq/rails.rb +29 -6
  39. data/lib/sidekiq/redis_client_adapter.rb +96 -0
  40. data/lib/sidekiq/redis_connection.rb +17 -88
  41. data/lib/sidekiq/ring_buffer.rb +29 -0
  42. data/lib/sidekiq/scheduled.rb +101 -44
  43. data/lib/sidekiq/testing/inline.rb +4 -4
  44. data/lib/sidekiq/testing.rb +41 -68
  45. data/lib/sidekiq/transaction_aware_client.rb +44 -0
  46. data/lib/sidekiq/version.rb +2 -1
  47. data/lib/sidekiq/web/action.rb +3 -3
  48. data/lib/sidekiq/web/application.rb +47 -13
  49. data/lib/sidekiq/web/csrf_protection.rb +3 -3
  50. data/lib/sidekiq/web/helpers.rb +36 -33
  51. data/lib/sidekiq/web.rb +10 -17
  52. data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
  53. data/lib/sidekiq.rb +86 -201
  54. data/sidekiq.gemspec +12 -10
  55. data/web/assets/javascripts/application.js +131 -60
  56. data/web/assets/javascripts/base-charts.js +106 -0
  57. data/web/assets/javascripts/chart.min.js +13 -0
  58. data/web/assets/javascripts/chartjs-plugin-annotation.min.js +7 -0
  59. data/web/assets/javascripts/dashboard-charts.js +166 -0
  60. data/web/assets/javascripts/dashboard.js +36 -273
  61. data/web/assets/javascripts/metrics.js +264 -0
  62. data/web/assets/stylesheets/application-dark.css +23 -23
  63. data/web/assets/stylesheets/application-rtl.css +2 -95
  64. data/web/assets/stylesheets/application.css +73 -402
  65. data/web/locales/ar.yml +70 -70
  66. data/web/locales/cs.yml +62 -62
  67. data/web/locales/da.yml +60 -53
  68. data/web/locales/de.yml +65 -65
  69. data/web/locales/el.yml +43 -24
  70. data/web/locales/en.yml +82 -69
  71. data/web/locales/es.yml +68 -68
  72. data/web/locales/fa.yml +65 -65
  73. data/web/locales/fr.yml +81 -67
  74. data/web/locales/gd.yml +99 -0
  75. data/web/locales/he.yml +65 -64
  76. data/web/locales/hi.yml +59 -59
  77. data/web/locales/it.yml +53 -53
  78. data/web/locales/ja.yml +73 -68
  79. data/web/locales/ko.yml +52 -52
  80. data/web/locales/lt.yml +66 -66
  81. data/web/locales/nb.yml +61 -61
  82. data/web/locales/nl.yml +52 -52
  83. data/web/locales/pl.yml +45 -45
  84. data/web/locales/pt-br.yml +63 -55
  85. data/web/locales/pt.yml +51 -51
  86. data/web/locales/ru.yml +67 -66
  87. data/web/locales/sv.yml +53 -53
  88. data/web/locales/ta.yml +60 -60
  89. data/web/locales/uk.yml +62 -61
  90. data/web/locales/ur.yml +64 -64
  91. data/web/locales/vi.yml +67 -67
  92. data/web/locales/zh-cn.yml +43 -16
  93. data/web/locales/zh-tw.yml +42 -8
  94. data/web/views/_footer.erb +6 -3
  95. data/web/views/_job_info.erb +18 -2
  96. data/web/views/_metrics_period_select.erb +12 -0
  97. data/web/views/_nav.erb +1 -1
  98. data/web/views/_paging.erb +2 -0
  99. data/web/views/_poll_link.erb +3 -6
  100. data/web/views/_summary.erb +7 -7
  101. data/web/views/busy.erb +44 -28
  102. data/web/views/dashboard.erb +44 -12
  103. data/web/views/layout.erb +1 -1
  104. data/web/views/metrics.erb +82 -0
  105. data/web/views/metrics_for_job.erb +68 -0
  106. data/web/views/morgue.erb +5 -9
  107. data/web/views/queue.erb +24 -24
  108. data/web/views/queues.erb +4 -2
  109. data/web/views/retries.erb +5 -9
  110. data/web/views/scheduled.erb +12 -13
  111. metadata +62 -31
  112. data/LICENSE +0 -9
  113. data/lib/generators/sidekiq/worker_generator.rb +0 -57
  114. data/lib/sidekiq/delay.rb +0 -41
  115. data/lib/sidekiq/exception_handler.rb +0 -27
  116. data/lib/sidekiq/extensions/action_mailer.rb +0 -48
  117. data/lib/sidekiq/extensions/active_record.rb +0 -43
  118. data/lib/sidekiq/extensions/class_methods.rb +0 -43
  119. data/lib/sidekiq/extensions/generic_proxy.rb +0 -33
  120. data/lib/sidekiq/worker.rb +0 -244
@@ -1,14 +1,10 @@
1
- <header class="row">
2
- <div class="col-sm-5">
3
- <h3><%= t('Retries') %></h3>
4
- </div>
1
+ <div class="header-container">
2
+ <h1><%= t('Retries') %></h1>
5
3
  <% if @retries.size > 0 && @total_size > @count %>
6
- <div class="col-sm-4">
7
- <%= erb :_paging, locals: { url: "#{root_path}retries" } %>
8
- </div>
4
+ <%= erb :_paging, locals: { url: "#{root_path}retries" } %>
9
5
  <% end %>
10
6
  <%= filtering('retries') %>
11
- </header>
7
+ </div>
12
8
 
13
9
  <% if @retries.size > 0 %>
14
10
  <form action="<%= root_path %>retries" method="post">
@@ -34,7 +30,7 @@
34
30
  <tr>
35
31
  <td class="table-checkbox">
36
32
  <label>
37
- <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' />
33
+ <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' class='shift_clickable' />
38
34
  </label>
39
35
  </td>
40
36
  <td>
@@ -1,25 +1,22 @@
1
- <header class="row">
2
- <div class="col-sm-5">
3
- <h3><%= t('ScheduledJobs') %></h3>
4
- </div>
1
+ <div class="header-container">
2
+ <h1><%= t('ScheduledJobs') %></h1>
5
3
  <% if @scheduled.size > 0 && @total_size > @count %>
6
- <div class="col-sm-4">
7
- <%= erb :_paging, locals: { url: "#{root_path}scheduled" } %>
8
- </div>
4
+ <%= erb :_paging, locals: { url: "#{root_path}scheduled" } %>
9
5
  <% end %>
10
6
  <%= filtering('scheduled') %>
11
- </header>
7
+ </div>
12
8
 
13
9
  <% if @scheduled.size > 0 %>
14
-
15
10
  <form action="<%= root_path %>scheduled" method="post">
16
11
  <%= csrf_tag %>
17
12
  <div class="table_container">
18
13
  <table class="table table-striped table-bordered table-hover">
19
14
  <thead>
20
15
  <tr>
21
- <th class="checkbox-column">
22
- <input type="checkbox" class="check_all" />
16
+ <th class="table-checkbox checkbox-column">
17
+ <label>
18
+ <input type="checkbox" class="check_all" />
19
+ </label>
23
20
  </th>
24
21
  <th><%= t('When') %></th>
25
22
  <th><%= t('Queue') %></th>
@@ -29,8 +26,10 @@
29
26
  </thead>
30
27
  <% @scheduled.each do |entry| %>
31
28
  <tr>
32
- <td>
33
- <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' />
29
+ <td class="table-checkbox">
30
+ <label>
31
+ <input type='checkbox' name='key[]' value='<%= job_params(entry.item, entry.score) %>' class='shift_clickable' />
32
+ </label>
34
33
  </td>
35
34
  <td>
36
35
  <a href="<%= root_path %>scheduled/<%= job_params(entry.item, entry.score) %>"><%= relative_time(entry.at) %></a>
metadata CHANGED
@@ -1,60 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.2
4
+ version: 7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2023-06-14 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
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0
19
+ version: 0.14.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0
26
+ version: 0.14.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: connection_pool
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.2
33
+ version: 2.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.2.2
40
+ version: 2.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
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
+ - - "<"
46
60
  - !ruby/object:Gem::Version
47
- version: '2.0'
61
+ version: '2'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - "<"
53
67
  - !ruby/object:Gem::Version
54
- version: '2.0'
68
+ version: '2'
55
69
  description: Simple, efficient background processing for Ruby.
56
70
  email:
57
- - mperham@gmail.com
71
+ - info@contribsys.com
58
72
  executables:
59
73
  - sidekiq
60
74
  - sidekiqmon
@@ -62,45 +76,52 @@ extensions: []
62
76
  extra_rdoc_files: []
63
77
  files:
64
78
  - Changes.md
65
- - LICENSE
79
+ - LICENSE.txt
66
80
  - README.md
67
81
  - bin/sidekiq
68
82
  - bin/sidekiqload
69
83
  - bin/sidekiqmon
70
- - lib/generators/sidekiq/templates/worker.rb.erb
71
- - lib/generators/sidekiq/templates/worker_spec.rb.erb
72
- - lib/generators/sidekiq/templates/worker_test.rb.erb
73
- - lib/generators/sidekiq/worker_generator.rb
84
+ - lib/generators/sidekiq/job_generator.rb
85
+ - lib/generators/sidekiq/templates/job.rb.erb
86
+ - lib/generators/sidekiq/templates/job_spec.rb.erb
87
+ - lib/generators/sidekiq/templates/job_test.rb.erb
74
88
  - lib/sidekiq.rb
75
89
  - lib/sidekiq/api.rb
90
+ - lib/sidekiq/capsule.rb
76
91
  - lib/sidekiq/cli.rb
77
92
  - lib/sidekiq/client.rb
78
- - lib/sidekiq/delay.rb
79
- - lib/sidekiq/exception_handler.rb
80
- - lib/sidekiq/extensions/action_mailer.rb
81
- - lib/sidekiq/extensions/active_record.rb
82
- - lib/sidekiq/extensions/class_methods.rb
83
- - lib/sidekiq/extensions/generic_proxy.rb
93
+ - lib/sidekiq/component.rb
94
+ - lib/sidekiq/config.rb
95
+ - lib/sidekiq/deploy.rb
96
+ - lib/sidekiq/embedded.rb
84
97
  - lib/sidekiq/fetch.rb
85
98
  - lib/sidekiq/job.rb
86
99
  - lib/sidekiq/job_logger.rb
87
100
  - lib/sidekiq/job_retry.rb
101
+ - lib/sidekiq/job_util.rb
88
102
  - lib/sidekiq/launcher.rb
89
103
  - lib/sidekiq/logger.rb
90
104
  - lib/sidekiq/manager.rb
105
+ - lib/sidekiq/metrics/query.rb
106
+ - lib/sidekiq/metrics/shared.rb
107
+ - lib/sidekiq/metrics/tracking.rb
91
108
  - lib/sidekiq/middleware/chain.rb
109
+ - lib/sidekiq/middleware/current_attributes.rb
92
110
  - lib/sidekiq/middleware/i18n.rb
111
+ - lib/sidekiq/middleware/modules.rb
93
112
  - lib/sidekiq/monitor.rb
94
113
  - lib/sidekiq/paginator.rb
95
114
  - lib/sidekiq/processor.rb
96
115
  - lib/sidekiq/rails.rb
116
+ - lib/sidekiq/redis_client_adapter.rb
97
117
  - lib/sidekiq/redis_connection.rb
118
+ - lib/sidekiq/ring_buffer.rb
98
119
  - lib/sidekiq/scheduled.rb
99
120
  - lib/sidekiq/sd_notify.rb
100
121
  - lib/sidekiq/systemd.rb
101
122
  - lib/sidekiq/testing.rb
102
123
  - lib/sidekiq/testing/inline.rb
103
- - lib/sidekiq/util.rb
124
+ - lib/sidekiq/transaction_aware_client.rb
104
125
  - lib/sidekiq/version.rb
105
126
  - lib/sidekiq/web.rb
106
127
  - lib/sidekiq/web/action.rb
@@ -108,14 +129,19 @@ files:
108
129
  - lib/sidekiq/web/csrf_protection.rb
109
130
  - lib/sidekiq/web/helpers.rb
110
131
  - lib/sidekiq/web/router.rb
111
- - lib/sidekiq/worker.rb
132
+ - lib/sidekiq/worker_compatibility_alias.rb
112
133
  - sidekiq.gemspec
113
134
  - web/assets/images/apple-touch-icon.png
114
135
  - web/assets/images/favicon.ico
115
136
  - web/assets/images/logo.png
116
137
  - web/assets/images/status.png
117
138
  - web/assets/javascripts/application.js
139
+ - web/assets/javascripts/base-charts.js
140
+ - web/assets/javascripts/chart.min.js
141
+ - web/assets/javascripts/chartjs-plugin-annotation.min.js
142
+ - web/assets/javascripts/dashboard-charts.js
118
143
  - web/assets/javascripts/dashboard.js
144
+ - web/assets/javascripts/metrics.js
119
145
  - web/assets/stylesheets/application-dark.css
120
146
  - web/assets/stylesheets/application-rtl.css
121
147
  - web/assets/stylesheets/application.css
@@ -130,6 +156,7 @@ files:
130
156
  - web/locales/es.yml
131
157
  - web/locales/fa.yml
132
158
  - web/locales/fr.yml
159
+ - web/locales/gd.yml
133
160
  - web/locales/he.yml
134
161
  - web/locales/hi.yml
135
162
  - web/locales/it.yml
@@ -151,6 +178,7 @@ files:
151
178
  - web/locales/zh-tw.yml
152
179
  - web/views/_footer.erb
153
180
  - web/views/_job_info.erb
181
+ - web/views/_metrics_period_select.erb
154
182
  - web/views/_nav.erb
155
183
  - web/views/_paging.erb
156
184
  - web/views/_poll_link.erb
@@ -160,6 +188,8 @@ files:
160
188
  - web/views/dashboard.erb
161
189
  - web/views/dead.erb
162
190
  - web/views/layout.erb
191
+ - web/views/metrics.erb
192
+ - web/views/metrics_for_job.erb
163
193
  - web/views/morgue.erb
164
194
  - web/views/queue.erb
165
195
  - web/views/queues.erb
@@ -172,10 +202,11 @@ licenses:
172
202
  - LGPL-3.0
173
203
  metadata:
174
204
  homepage_uri: https://sidekiq.org
175
- bug_tracker_uri: https://github.com/mperham/sidekiq/issues
176
- documentation_uri: https://github.com/mperham/sidekiq/wiki
177
- changelog_uri: https://github.com/mperham/sidekiq/blob/master/Changes.md
178
- source_code_uri: https://github.com/mperham/sidekiq
205
+ bug_tracker_uri: https://github.com/sidekiq/sidekiq/issues
206
+ documentation_uri: https://github.com/sidekiq/sidekiq/wiki
207
+ changelog_uri: https://github.com/sidekiq/sidekiq/blob/main/Changes.md
208
+ source_code_uri: https://github.com/sidekiq/sidekiq
209
+ rubygems_mfa_required: 'true'
179
210
  post_install_message:
180
211
  rdoc_options: []
181
212
  require_paths:
@@ -184,14 +215,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
215
  requirements:
185
216
  - - ">="
186
217
  - !ruby/object:Gem::Version
187
- version: 2.5.0
218
+ version: 2.7.0
188
219
  required_rubygems_version: !ruby/object:Gem::Requirement
189
220
  requirements:
190
221
  - - ">="
191
222
  - !ruby/object:Gem::Version
192
223
  version: '0'
193
224
  requirements: []
194
- rubygems_version: 3.1.4
225
+ rubygems_version: 3.4.7
195
226
  signing_key:
196
227
  specification_version: 4
197
228
  summary: Simple, efficient background processing for Ruby
data/LICENSE DELETED
@@ -1,9 +0,0 @@
1
- Copyright (c) Contributed Systems LLC
2
-
3
- Sidekiq is an Open Source project licensed under the terms of
4
- the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
- for license text.
6
-
7
- Sidekiq Pro has a commercial-friendly license allowing private forks
8
- and modifications of Sidekiq. Please see https://sidekiq.org/products/pro.html for
9
- more detail. You can find the commercial license terms in COMM-LICENSE.txt.
@@ -1,57 +0,0 @@
1
- require "rails/generators/named_base"
2
-
3
- module Sidekiq
4
- module Generators # :nodoc:
5
- class WorkerGenerator < ::Rails::Generators::NamedBase # :nodoc:
6
- desc "This generator creates a Sidekiq Worker in app/workers and a corresponding test"
7
-
8
- check_class_collision suffix: "Worker"
9
-
10
- def self.default_generator_root
11
- File.dirname(__FILE__)
12
- end
13
-
14
- def create_worker_file
15
- template "worker.rb.erb", File.join("app/workers", class_path, "#{file_name}_worker.rb")
16
- end
17
-
18
- def create_test_file
19
- return unless test_framework
20
-
21
- if test_framework == :rspec
22
- create_worker_spec
23
- else
24
- create_worker_test
25
- end
26
- end
27
-
28
- private
29
-
30
- def create_worker_spec
31
- template_file = File.join(
32
- "spec/workers",
33
- class_path,
34
- "#{file_name}_worker_spec.rb"
35
- )
36
- template "worker_spec.rb.erb", template_file
37
- end
38
-
39
- def create_worker_test
40
- template_file = File.join(
41
- "test/workers",
42
- class_path,
43
- "#{file_name}_worker_test.rb"
44
- )
45
- template "worker_test.rb.erb", template_file
46
- end
47
-
48
- def file_name
49
- @_file_name ||= super.sub(/_?worker\z/i, "")
50
- end
51
-
52
- def test_framework
53
- ::Rails.application.config.generators.options[:rails][:test_framework]
54
- end
55
- end
56
- end
57
- end
data/lib/sidekiq/delay.rb DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sidekiq
4
- module Extensions
5
- def self.enable_delay!
6
- if defined?(::ActiveSupport)
7
- require "sidekiq/extensions/active_record"
8
- require "sidekiq/extensions/action_mailer"
9
-
10
- # Need to patch Psych so it can autoload classes whose names are serialized
11
- # in the delayed YAML.
12
- Psych::Visitors::ToRuby.prepend(Sidekiq::Extensions::PsychAutoload)
13
-
14
- ActiveSupport.on_load(:active_record) do
15
- include Sidekiq::Extensions::ActiveRecord
16
- end
17
- ActiveSupport.on_load(:action_mailer) do
18
- extend Sidekiq::Extensions::ActionMailer
19
- end
20
- end
21
-
22
- require "sidekiq/extensions/class_methods"
23
- Module.__send__(:include, Sidekiq::Extensions::Klass)
24
- end
25
-
26
- module PsychAutoload
27
- def resolve_class(klass_name)
28
- return nil if !klass_name || klass_name.empty?
29
- # constantize
30
- names = klass_name.split("::")
31
- names.shift if names.empty? || names.first.empty?
32
-
33
- names.inject(Object) do |constant, name|
34
- constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
35
- end
36
- rescue NameError
37
- super
38
- end
39
- end
40
- end
41
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "sidekiq"
4
-
5
- module Sidekiq
6
- module ExceptionHandler
7
- class Logger
8
- def call(ex, ctx)
9
- Sidekiq.logger.warn(Sidekiq.dump_json(ctx)) unless ctx.empty?
10
- Sidekiq.logger.warn("#{ex.class.name}: #{ex.message}")
11
- Sidekiq.logger.warn(ex.backtrace.join("\n")) unless ex.backtrace.nil?
12
- end
13
-
14
- Sidekiq.error_handlers << Sidekiq::ExceptionHandler::Logger.new
15
- end
16
-
17
- def handle_exception(ex, ctx = {})
18
- Sidekiq.error_handlers.each do |handler|
19
- handler.call(ex, ctx)
20
- rescue => ex
21
- Sidekiq.logger.error "!!! ERROR HANDLER THREW AN ERROR !!!"
22
- Sidekiq.logger.error ex
23
- Sidekiq.logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
24
- end
25
- end
26
- end
27
- 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
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