sidekiq 6.4.1 → 6.5.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +47 -1
  3. data/README.md +1 -1
  4. data/bin/sidekiqload +16 -10
  5. data/lib/sidekiq/.DS_Store +0 -0
  6. data/lib/sidekiq/api.rb +73 -46
  7. data/lib/sidekiq/cli.rb +38 -37
  8. data/lib/sidekiq/client.rb +25 -26
  9. data/lib/sidekiq/component.rb +64 -0
  10. data/lib/sidekiq/delay.rb +1 -1
  11. data/lib/sidekiq/extensions/generic_proxy.rb +1 -1
  12. data/lib/sidekiq/fetch.rb +16 -14
  13. data/lib/sidekiq/job_retry.rb +29 -28
  14. data/lib/sidekiq/job_util.rb +15 -9
  15. data/lib/sidekiq/launcher.rb +31 -29
  16. data/lib/sidekiq/logger.rb +5 -19
  17. data/lib/sidekiq/manager.rb +28 -25
  18. data/lib/sidekiq/middleware/chain.rb +22 -13
  19. data/lib/sidekiq/middleware/current_attributes.rb +4 -0
  20. data/lib/sidekiq/middleware/i18n.rb +6 -4
  21. data/lib/sidekiq/middleware/modules.rb +21 -0
  22. data/lib/sidekiq/monitor.rb +1 -1
  23. data/lib/sidekiq/paginator.rb +2 -2
  24. data/lib/sidekiq/processor.rb +38 -38
  25. data/lib/sidekiq/rails.rb +15 -8
  26. data/lib/sidekiq/redis_client_adapter.rb +154 -0
  27. data/lib/sidekiq/redis_connection.rb +81 -48
  28. data/lib/sidekiq/ring_buffer.rb +29 -0
  29. data/lib/sidekiq/scheduled.rb +11 -10
  30. data/lib/sidekiq/testing/inline.rb +4 -4
  31. data/lib/sidekiq/testing.rb +37 -36
  32. data/lib/sidekiq/transaction_aware_client.rb +45 -0
  33. data/lib/sidekiq/version.rb +1 -1
  34. data/lib/sidekiq/web/csrf_protection.rb +2 -2
  35. data/lib/sidekiq/web/helpers.rb +4 -4
  36. data/lib/sidekiq/worker.rb +18 -13
  37. data/lib/sidekiq.rb +97 -30
  38. data/web/assets/javascripts/application.js +58 -26
  39. data/web/assets/stylesheets/application.css +1 -2
  40. data/web/locales/pt-br.yml +27 -9
  41. data/web/views/_summary.erb +1 -1
  42. data/web/views/busy.erb +3 -3
  43. metadata +8 -4
  44. data/lib/sidekiq/exception_handler.rb +0 -27
  45. data/lib/sidekiq/util.rb +0 -108
@@ -9,7 +9,9 @@ var ready = (callback) => {
9
9
  else document.addEventListener("DOMContentLoaded", callback);
10
10
  }
11
11
 
12
- ready(() => {
12
+ ready(addListeners)
13
+
14
+ function addListeners() {
13
15
  document.querySelectorAll(".check_all").forEach(node => {
14
16
  node.addEventListener("click", event => {
15
17
  node.closest('table').querySelectorAll('input[type=checkbox]').forEach(inp => { inp.checked = !!node.checked; });
@@ -26,42 +28,48 @@ ready(() => {
26
28
  })
27
29
 
28
30
  document.querySelectorAll("[data-toggle]").forEach(node => {
29
- node.addEventListener("click", event => {
30
- var targName = node.getAttribute("data-toggle");
31
- var full = document.getElementById(targName + "_full");
32
- if (full.style.display == "block") {
33
- full.style.display = 'none';
34
- } else {
35
- full.style.display = 'block';
36
- }
37
- })
31
+ node.addEventListener("click", addDataToggleListeners)
38
32
  })
39
33
 
40
34
  updateFuzzyTimes();
35
+ setLivePollFromUrl();
41
36
 
42
37
  var buttons = document.querySelectorAll(".live-poll");
43
38
  if (buttons.length > 0) {
44
39
  buttons.forEach(node => {
45
- node.addEventListener("click", event => {
46
- if (localStorage.sidekiqLivePoll == "enabled") {
47
- localStorage.sidekiqLivePoll = "disabled";
48
- clearTimeout(livePollTimer);
49
- livePollTimer = null;
50
- } else {
51
- localStorage.sidekiqLivePoll = "enabled";
52
- livePollCallback();
53
- }
54
-
55
- updateLivePollButton();
56
- })
40
+ node.addEventListener("click", addPollingListeners)
57
41
  });
58
42
 
59
43
  updateLivePollButton();
60
- if (localStorage.sidekiqLivePoll == "enabled") {
44
+ if (localStorage.sidekiqLivePoll == "enabled" && !livePollTimer) {
61
45
  scheduleLivePoll();
62
46
  }
63
47
  }
64
- })
48
+ }
49
+
50
+ function addPollingListeners(_event) {
51
+ if (localStorage.sidekiqLivePoll == "enabled") {
52
+ localStorage.sidekiqLivePoll = "disabled";
53
+ clearTimeout(livePollTimer);
54
+ livePollTimer = null;
55
+ } else {
56
+ localStorage.sidekiqLivePoll = "enabled";
57
+ livePollCallback();
58
+ }
59
+
60
+ updateLivePollButton();
61
+ }
62
+
63
+ function addDataToggleListeners(event) {
64
+ var source = event.target || event.srcElement;
65
+ var targName = source.getAttribute("data-toggle");
66
+ var full = document.getElementById(targName + "_full");
67
+ if (full.style.display == "block") {
68
+ full.style.display = 'none';
69
+ } else {
70
+ full.style.display = 'block';
71
+ }
72
+ }
65
73
 
66
74
  function updateFuzzyTimes() {
67
75
  var locale = document.body.getAttribute("data-locale");
@@ -76,6 +84,14 @@ function updateFuzzyTimes() {
76
84
  t.cancel();
77
85
  }
78
86
 
87
+ function setLivePollFromUrl() {
88
+ var url_params = new URL(window.location.href).searchParams
89
+
90
+ if (url_params.get("poll") == "true") {
91
+ localStorage.sidekiqLivePoll = "enabled";
92
+ }
93
+ }
94
+
79
95
  function updateLivePollButton() {
80
96
  if (localStorage.sidekiqLivePoll == "enabled") {
81
97
  document.querySelectorAll('.live-poll-stop').forEach(box => { box.style.display = "inline-block" })
@@ -89,7 +105,19 @@ function updateLivePollButton() {
89
105
  function livePollCallback() {
90
106
  clearTimeout(livePollTimer);
91
107
 
92
- fetch(window.location.href).then(resp => resp.text()).then(replacePage).finally(scheduleLivePoll)
108
+ fetch(window.location.href)
109
+ .then(checkResponse)
110
+ .then(resp => resp.text())
111
+ .then(replacePage)
112
+ .catch(showError)
113
+ .finally(scheduleLivePoll)
114
+ }
115
+
116
+ function checkResponse(resp) {
117
+ if (!resp.ok) {
118
+ throw response.error();
119
+ }
120
+ return resp
93
121
  }
94
122
 
95
123
  function scheduleLivePoll() {
@@ -107,5 +135,9 @@ function replacePage(text) {
107
135
  var header_status = doc.querySelector('.status')
108
136
  document.querySelector('.status').replaceWith(header_status)
109
137
 
110
- updateFuzzyTimes();
138
+ addListeners();
139
+ }
140
+
141
+ function showError(error) {
142
+ console.error(error)
111
143
  }
@@ -202,8 +202,7 @@ table .table-checkbox label {
202
202
 
203
203
  .navbar .navbar-brand .status {
204
204
  color: #585454;
205
- display: inline-block;
206
- width: 75px;
205
+ display: inline;
207
206
  }
208
207
 
209
208
 
@@ -8,6 +8,7 @@
8
8
  History: Histórico
9
9
  Busy: Ocupados
10
10
  Processed: Processados
11
+ Utilization: Utilização
11
12
  Failed: Falhas
12
13
  Scheduled: Agendados
13
14
  Retries: Tentativas
@@ -26,18 +27,20 @@
26
27
  Delete: Apagar
27
28
  AddToQueue: Adicionar à fila
28
29
  AreYouSureDeleteJob: Deseja deletar esta tarefa?
29
- AreYouSureDeleteQueue: Deseja deletar a %{queue} fila?
30
+ AreYouSureDeleteQueue: Deseja deletar a fila %{queue}? Isso irá deletar todas as tarefas desta fila.
30
31
  Queues: Filas
31
32
  Size: Tamanho
32
33
  Actions: Ações
33
34
  NextRetry: Próxima Tentativa
34
35
  RetryCount: Número de Tentativas
35
36
  RetryNow: Tentar novamente agora
37
+ Kill: Matar
36
38
  LastRetry: Última tentativa
37
39
  OriginallyFailed: Falhou originalmente
38
40
  AreYouSure: Tem certeza?
39
41
  DeleteAll: Apagar tudo
40
42
  RetryAll: Tentar tudo novamente
43
+ KillAll: Matar todas
41
44
  NoRetriesFound: Nenhuma tentativa encontrada
42
45
  Error: Erro
43
46
  ErrorClass: Classe de erro
@@ -58,11 +61,26 @@
58
61
  OneMonth: 1 mês
59
62
  ThreeMonths: 3 meses
60
63
  SixMonths: 6 meses
61
- Failures : Falhas
62
- DeadJobs : Tarefas mortas
63
- NoDeadJobsFound : Nenhuma tarefa morta foi encontrada
64
- Dead : Morta
65
- Processes : Processos
66
- Thread : Thread
67
- Threads : Threads
68
- Jobs : Tarefas
64
+ Failures: Falhas
65
+ DeadJobs: Tarefas mortas
66
+ NoDeadJobsFound: Nenhuma tarefa morta foi encontrada
67
+ Dead: Morta
68
+ Process: Processo
69
+ Processes: Processos
70
+ Name: Nome
71
+ Thread: Thread
72
+ Threads: Threads
73
+ Jobs: Tarefas
74
+ Paused: Pausado
75
+ Stop: Parar
76
+ Quiet: Silenciar
77
+ StopAll: Parar Todos
78
+ QuietAll: Silenciar Todos
79
+ PollingInterval: Intervalo de Polling
80
+ Plugins: Plug-ins
81
+ NotYetEnqueued: Ainda não enfileirado
82
+ CreatedAt: Criado em
83
+ BackToApp: De volta ao aplicativo
84
+ Latency: Latência
85
+ Pause: Pausar
86
+ Unpause: Despausar
@@ -9,7 +9,7 @@
9
9
  </li>
10
10
  <li class="busy col-sm-1">
11
11
  <a href="<%= root_path %>busy">
12
- <span id="txtBusy" class="count"><%= number_with_delimiter(workers.size) %></span>
12
+ <span id="txtBusy" class="count"><%= number_with_delimiter(workset.size) %></span>
13
13
  <span class="desc"><%= t('Busy') %></span>
14
14
  </a>
15
15
  </li>
data/web/views/busy.erb CHANGED
@@ -15,7 +15,7 @@
15
15
  <p><%= t('Threads') %></p>
16
16
  </div>
17
17
  <div class="stat">
18
- <h3><%= ws = workers.size; number_with_delimiter(ws) %></h3>
18
+ <h3><%= ws = workset.size; number_with_delimiter(ws) %></h3>
19
19
  <p><%= t('Busy') %></p>
20
20
  </div>
21
21
  <div class="stat">
@@ -48,7 +48,7 @@
48
48
  <thead>
49
49
  <th><%= t('Name') %></th>
50
50
  <th><%= t('Started') %></th>
51
- <th class="col-sm-1"><%= t('RSS') %><a href="https://github.com/mperham/sidekiq/wiki/Memory#rss"><span class="info-circle" title="Click to learn more about RSS">?</span></a></th>
51
+ <th class="col-sm-1"><%= t('RSS') %><a target="blank" href="https://github.com/mperham/sidekiq/wiki/Memory#rss"><span class="info-circle" title="Click to learn more about RSS">?</span></a></th>
52
52
  <th class="col-sm-1"><%= t('Threads') %></th>
53
53
  <th class="col-sm-1"><%= t('Busy') %></th>
54
54
  <th>&nbsp;</th>
@@ -109,7 +109,7 @@
109
109
  <th><%= t('Arguments') %></th>
110
110
  <th><%= t('Started') %></th>
111
111
  </thead>
112
- <% workers.each do |process, thread, msg| %>
112
+ <% workset.each do |process, thread, msg| %>
113
113
  <% job = Sidekiq::JobRecord.new(msg['payload']) %>
114
114
  <tr>
115
115
  <td><%= process %></td>
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: 6.4.1
4
+ version: 6.5.1
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-02-07 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -72,11 +72,12 @@ files:
72
72
  - lib/generators/sidekiq/templates/job_spec.rb.erb
73
73
  - lib/generators/sidekiq/templates/job_test.rb.erb
74
74
  - lib/sidekiq.rb
75
+ - lib/sidekiq/.DS_Store
75
76
  - lib/sidekiq/api.rb
76
77
  - lib/sidekiq/cli.rb
77
78
  - lib/sidekiq/client.rb
79
+ - lib/sidekiq/component.rb
78
80
  - lib/sidekiq/delay.rb
79
- - lib/sidekiq/exception_handler.rb
80
81
  - lib/sidekiq/extensions/action_mailer.rb
81
82
  - lib/sidekiq/extensions/active_record.rb
82
83
  - lib/sidekiq/extensions/class_methods.rb
@@ -92,17 +93,20 @@ files:
92
93
  - lib/sidekiq/middleware/chain.rb
93
94
  - lib/sidekiq/middleware/current_attributes.rb
94
95
  - lib/sidekiq/middleware/i18n.rb
96
+ - lib/sidekiq/middleware/modules.rb
95
97
  - lib/sidekiq/monitor.rb
96
98
  - lib/sidekiq/paginator.rb
97
99
  - lib/sidekiq/processor.rb
98
100
  - lib/sidekiq/rails.rb
101
+ - lib/sidekiq/redis_client_adapter.rb
99
102
  - lib/sidekiq/redis_connection.rb
103
+ - lib/sidekiq/ring_buffer.rb
100
104
  - lib/sidekiq/scheduled.rb
101
105
  - lib/sidekiq/sd_notify.rb
102
106
  - lib/sidekiq/systemd.rb
103
107
  - lib/sidekiq/testing.rb
104
108
  - lib/sidekiq/testing/inline.rb
105
- - lib/sidekiq/util.rb
109
+ - lib/sidekiq/transaction_aware_client.rb
106
110
  - lib/sidekiq/version.rb
107
111
  - lib/sidekiq/web.rb
108
112
  - lib/sidekiq/web/action.rb
@@ -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
data/lib/sidekiq/util.rb DELETED
@@ -1,108 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "forwardable"
4
- require "socket"
5
- require "securerandom"
6
- require "sidekiq/exception_handler"
7
-
8
- module Sidekiq
9
- ##
10
- # This module is part of Sidekiq core and not intended for extensions.
11
- #
12
-
13
- class RingBuffer
14
- include Enumerable
15
- extend Forwardable
16
- def_delegators :@buf, :[], :each, :size
17
-
18
- def initialize(size, default = 0)
19
- @size = size
20
- @buf = Array.new(size, default)
21
- @index = 0
22
- end
23
-
24
- def <<(element)
25
- @buf[@index % @size] = element
26
- @index += 1
27
- element
28
- end
29
-
30
- def buffer
31
- @buf
32
- end
33
-
34
- def reset(default = 0)
35
- @buf.fill(default)
36
- end
37
- end
38
-
39
- module Util
40
- include ExceptionHandler
41
-
42
- # hack for quicker development / testing environment #2774
43
- PAUSE_TIME = $stdout.tty? ? 0.1 : 0.5
44
-
45
- # Wait for the orblock to be true or the deadline passed.
46
- def wait_for(deadline, &condblock)
47
- remaining = deadline - ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
48
- while remaining > PAUSE_TIME
49
- return if condblock.call
50
- sleep PAUSE_TIME
51
- remaining = deadline - ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
52
- end
53
- end
54
-
55
- def watchdog(last_words)
56
- yield
57
- rescue Exception => ex
58
- handle_exception(ex, {context: last_words})
59
- raise ex
60
- end
61
-
62
- def safe_thread(name, &block)
63
- Thread.new do
64
- Thread.current.name = name
65
- watchdog(name, &block)
66
- end
67
- end
68
-
69
- def logger
70
- Sidekiq.logger
71
- end
72
-
73
- def redis(&block)
74
- Sidekiq.redis(&block)
75
- end
76
-
77
- def tid
78
- Thread.current["sidekiq_tid"] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36)
79
- end
80
-
81
- def hostname
82
- ENV["DYNO"] || Socket.gethostname
83
- end
84
-
85
- def process_nonce
86
- @@process_nonce ||= SecureRandom.hex(6)
87
- end
88
-
89
- def identity
90
- @@identity ||= "#{hostname}:#{::Process.pid}:#{process_nonce}"
91
- end
92
-
93
- def fire_event(event, options = {})
94
- reverse = options[:reverse]
95
- reraise = options[:reraise]
96
-
97
- arr = Sidekiq.options[:lifecycle_events][event]
98
- arr.reverse! if reverse
99
- arr.each do |block|
100
- block.call
101
- rescue => ex
102
- handle_exception(ex, {context: "Exception during Sidekiq lifecycle event.", event: event})
103
- raise ex if reraise
104
- end
105
- arr.clear
106
- end
107
- end
108
- end