sidekiq 6.4.1 → 7.0.0

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.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +107 -5
  3. data/README.md +14 -13
  4. data/bin/sidekiq +3 -8
  5. data/bin/sidekiqload +26 -29
  6. data/lib/sidekiq/api.rb +232 -157
  7. data/lib/sidekiq/capsule.rb +110 -0
  8. data/lib/sidekiq/cli.rb +80 -86
  9. data/lib/sidekiq/client.rb +54 -42
  10. data/lib/sidekiq/component.rb +66 -0
  11. data/lib/sidekiq/config.rb +271 -0
  12. data/lib/sidekiq/deploy.rb +62 -0
  13. data/lib/sidekiq/embedded.rb +61 -0
  14. data/lib/sidekiq/fetch.rb +20 -19
  15. data/lib/sidekiq/job.rb +375 -10
  16. data/lib/sidekiq/job_logger.rb +1 -1
  17. data/lib/sidekiq/job_retry.rb +74 -53
  18. data/lib/sidekiq/job_util.rb +17 -11
  19. data/lib/sidekiq/launcher.rb +63 -69
  20. data/lib/sidekiq/logger.rb +6 -45
  21. data/lib/sidekiq/manager.rb +33 -32
  22. data/lib/sidekiq/metrics/query.rb +153 -0
  23. data/lib/sidekiq/metrics/shared.rb +95 -0
  24. data/lib/sidekiq/metrics/tracking.rb +134 -0
  25. data/lib/sidekiq/middleware/chain.rb +84 -42
  26. data/lib/sidekiq/middleware/current_attributes.rb +18 -17
  27. data/lib/sidekiq/middleware/i18n.rb +6 -4
  28. data/lib/sidekiq/middleware/modules.rb +21 -0
  29. data/lib/sidekiq/monitor.rb +1 -1
  30. data/lib/sidekiq/paginator.rb +10 -2
  31. data/lib/sidekiq/processor.rb +56 -59
  32. data/lib/sidekiq/rails.rb +10 -9
  33. data/lib/sidekiq/redis_client_adapter.rb +118 -0
  34. data/lib/sidekiq/redis_connection.rb +13 -82
  35. data/lib/sidekiq/ring_buffer.rb +29 -0
  36. data/lib/sidekiq/scheduled.rb +65 -37
  37. data/lib/sidekiq/testing/inline.rb +4 -4
  38. data/lib/sidekiq/testing.rb +41 -68
  39. data/lib/sidekiq/transaction_aware_client.rb +44 -0
  40. data/lib/sidekiq/version.rb +2 -1
  41. data/lib/sidekiq/web/action.rb +3 -3
  42. data/lib/sidekiq/web/application.rb +22 -6
  43. data/lib/sidekiq/web/csrf_protection.rb +3 -3
  44. data/lib/sidekiq/web/helpers.rb +21 -19
  45. data/lib/sidekiq/web.rb +3 -14
  46. data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
  47. data/lib/sidekiq.rb +84 -207
  48. data/sidekiq.gemspec +29 -5
  49. data/web/assets/javascripts/application.js +58 -26
  50. data/web/assets/javascripts/base-charts.js +106 -0
  51. data/web/assets/javascripts/chart.min.js +13 -0
  52. data/web/assets/javascripts/chartjs-plugin-annotation.min.js +7 -0
  53. data/web/assets/javascripts/dashboard-charts.js +166 -0
  54. data/web/assets/javascripts/dashboard.js +3 -240
  55. data/web/assets/javascripts/metrics.js +236 -0
  56. data/web/assets/stylesheets/application-rtl.css +2 -91
  57. data/web/assets/stylesheets/application.css +64 -297
  58. data/web/locales/ar.yml +70 -70
  59. data/web/locales/cs.yml +62 -62
  60. data/web/locales/da.yml +52 -52
  61. data/web/locales/de.yml +65 -65
  62. data/web/locales/el.yml +43 -24
  63. data/web/locales/en.yml +82 -69
  64. data/web/locales/es.yml +68 -68
  65. data/web/locales/fa.yml +65 -65
  66. data/web/locales/fr.yml +67 -67
  67. data/web/locales/he.yml +65 -64
  68. data/web/locales/hi.yml +59 -59
  69. data/web/locales/it.yml +53 -53
  70. data/web/locales/ja.yml +71 -68
  71. data/web/locales/ko.yml +52 -52
  72. data/web/locales/lt.yml +66 -66
  73. data/web/locales/nb.yml +61 -61
  74. data/web/locales/nl.yml +52 -52
  75. data/web/locales/pl.yml +45 -45
  76. data/web/locales/pt-br.yml +63 -55
  77. data/web/locales/pt.yml +51 -51
  78. data/web/locales/ru.yml +67 -66
  79. data/web/locales/sv.yml +53 -53
  80. data/web/locales/ta.yml +60 -60
  81. data/web/locales/uk.yml +62 -61
  82. data/web/locales/ur.yml +64 -64
  83. data/web/locales/vi.yml +67 -67
  84. data/web/locales/zh-cn.yml +37 -11
  85. data/web/locales/zh-tw.yml +42 -8
  86. data/web/views/_footer.erb +5 -2
  87. data/web/views/_nav.erb +1 -1
  88. data/web/views/_summary.erb +1 -1
  89. data/web/views/busy.erb +9 -4
  90. data/web/views/dashboard.erb +36 -4
  91. data/web/views/metrics.erb +80 -0
  92. data/web/views/metrics_for_job.erb +69 -0
  93. data/web/views/queue.erb +5 -1
  94. metadata +69 -22
  95. data/lib/sidekiq/delay.rb +0 -43
  96. data/lib/sidekiq/exception_handler.rb +0 -27
  97. data/lib/sidekiq/extensions/action_mailer.rb +0 -48
  98. data/lib/sidekiq/extensions/active_record.rb +0 -43
  99. data/lib/sidekiq/extensions/class_methods.rb +0 -43
  100. data/lib/sidekiq/extensions/generic_proxy.rb +0 -33
  101. data/lib/sidekiq/util.rb +0 -108
  102. data/lib/sidekiq/worker.rb +0 -362
  103. /data/{LICENSE → LICENSE.txt} +0 -0
@@ -0,0 +1,236 @@
1
+ class JobMetricsOverviewChart extends BaseChart {
2
+ constructor(el, options) {
3
+ super(el, { ...options, chartType: "line" });
4
+ this.swatches = [];
5
+ this.visibleKls = options.visibleKls;
6
+
7
+ this.init();
8
+ }
9
+
10
+ get datasets() {
11
+ return Object.entries(this.options.series)
12
+ .filter(([kls, _]) => this.visibleKls.includes(kls))
13
+ .map(([kls, _]) => this.buildDataset(kls));
14
+ }
15
+
16
+ get metric() {
17
+ return this._metric || this.options.initialMetric;
18
+ }
19
+
20
+ set metric(m) {
21
+ this._metric = m;
22
+ }
23
+
24
+ registerSwatch(id) {
25
+ const el = document.getElementById(id);
26
+ el.addEventListener("change", () => this.toggleKls(el.value, el.checked));
27
+ this.swatches[el.value] = el;
28
+ this.updateSwatch(el.value, el.checked);
29
+ }
30
+
31
+ updateSwatch(kls, checked) {
32
+ const el = this.swatches[kls];
33
+ el.checked = checked;
34
+ el.style.color = this.colors.assignments[kls] || "";
35
+ }
36
+
37
+ toggleKls(kls, visible) {
38
+ if (visible) {
39
+ this.chart.data.datasets.push(this.buildDataset(kls));
40
+ } else {
41
+ const i = this.chart.data.datasets.findIndex((ds) => ds.label == kls);
42
+ this.colors.checkIn(kls);
43
+ this.chart.data.datasets.splice(i, 1);
44
+ }
45
+
46
+ this.updateSwatch(kls, visible);
47
+ this.update();
48
+ }
49
+
50
+ buildDataset(kls) {
51
+ const color = this.colors.checkOut(kls);
52
+
53
+ return {
54
+ label: kls,
55
+ data: this.options.series[kls],
56
+ borderColor: color,
57
+ backgroundColor: color,
58
+ borderWidth: 2,
59
+ pointRadius: 2,
60
+ };
61
+ }
62
+
63
+ get chartOptions() {
64
+ return {
65
+ ...super.chartOptions,
66
+ aspectRatio: 4,
67
+ scales: {
68
+ ...super.chartOptions.scales,
69
+ y: {
70
+ ...super.chartOptions.scales.y,
71
+ beginAtZero: true,
72
+ title: {
73
+ text: this.options.yLabel,
74
+ display: true,
75
+ },
76
+ },
77
+ },
78
+ plugins: {
79
+ ...super.chartOptions.plugins,
80
+ tooltip: {
81
+ ...super.chartOptions.plugins.tooltip,
82
+ callbacks: {
83
+ title: (items) => `${items[0].label} UTC`,
84
+ label: (item) =>
85
+ `${item.dataset.label}: ${item.parsed.y.toFixed(1)} ` +
86
+ `${this.options.units}`,
87
+ footer: (items) => {
88
+ const bucket = items[0].label;
89
+ const marks = this.options.marks.filter(([b, _]) => b == bucket);
90
+ return marks.map(
91
+ ([b, msg]) => `${this.options.markLabel}: ${msg}`
92
+ );
93
+ },
94
+ },
95
+ },
96
+ },
97
+ };
98
+ }
99
+ }
100
+
101
+ class HistTotalsChart extends BaseChart {
102
+ constructor(el, options) {
103
+ super(el, { ...options, chartType: "bar" });
104
+ this.init();
105
+ }
106
+
107
+ get datasets() {
108
+ return [
109
+ {
110
+ data: this.options.series,
111
+ backgroundColor: this.colors.primary,
112
+ borderWidth: 0,
113
+ },
114
+ ];
115
+ }
116
+
117
+ get chartOptions() {
118
+ return {
119
+ ...super.chartOptions,
120
+ aspectRatio: 6,
121
+ scales: {
122
+ ...super.chartOptions.scales,
123
+ y: {
124
+ ...super.chartOptions.scales.y,
125
+ beginAtZero: true,
126
+ title: {
127
+ text: this.options.yLabel,
128
+ display: true,
129
+ },
130
+ },
131
+ x: {
132
+ ...super.chartOptions.scales.x,
133
+ title: {
134
+ text: this.options.xLabel,
135
+ display: true,
136
+ },
137
+ },
138
+ },
139
+ plugins: {
140
+ ...super.chartOptions.plugins,
141
+ tooltip: {
142
+ ...super.chartOptions.plugins.tooltip,
143
+ callbacks: {
144
+ label: (item) => `${item.parsed.y} ${this.options.units}`,
145
+ },
146
+ },
147
+ },
148
+ };
149
+ }
150
+ }
151
+
152
+ class HistBubbleChart extends BaseChart {
153
+ constructor(el, options) {
154
+ super(el, { ...options, chartType: "bubble" });
155
+ this.init();
156
+ }
157
+
158
+ get datasets() {
159
+ const data = [];
160
+ let maxCount = 0;
161
+
162
+ Object.entries(this.options.hist).forEach(([bucket, hist]) => {
163
+ hist.forEach((count, histBucket) => {
164
+ if (count > 0) {
165
+ // histogram data is ordered fastest to slowest, but this.histIntervals is
166
+ // slowest to fastest (so it displays correctly on the chart).
167
+ const index = this.options.histIntervals.length - 1 - histBucket;
168
+
169
+ data.push({
170
+ x: bucket,
171
+ y: this.options.histIntervals[index] / 1000,
172
+ count: count,
173
+ });
174
+
175
+ if (count > maxCount) maxCount = count;
176
+ }
177
+ });
178
+ });
179
+
180
+ // Chart.js will not calculate the bubble size. We have to do that.
181
+ const maxRadius = this.el.offsetWidth / this.options.labels.length;
182
+ const minRadius = 1;
183
+ const multiplier = (maxRadius / maxCount) * 1.5;
184
+ data.forEach((entry) => {
185
+ entry.r = entry.count * multiplier + minRadius;
186
+ });
187
+
188
+ return [
189
+ {
190
+ data: data,
191
+ backgroundColor: this.colors.primary,
192
+ borderColor: this.colors.primary,
193
+ },
194
+ ];
195
+ }
196
+
197
+ get chartOptions() {
198
+ return {
199
+ ...super.chartOptions,
200
+ aspectRatio: 3,
201
+ scales: {
202
+ ...super.chartOptions.scales,
203
+ x: {
204
+ ...super.chartOptions.scales.x,
205
+ type: "category",
206
+ labels: this.options.labels,
207
+ },
208
+ y: {
209
+ ...super.chartOptions.scales.y,
210
+ title: {
211
+ text: this.options.yLabel,
212
+ display: true,
213
+ },
214
+ },
215
+ },
216
+ plugins: {
217
+ ...super.chartOptions.plugins,
218
+ tooltip: {
219
+ ...super.chartOptions.plugins.tooltip,
220
+ callbacks: {
221
+ title: (items) => `${items[0].raw.x} UTC`,
222
+ label: (item) =>
223
+ `${item.parsed.y} ${this.options.yUnits}: ${item.raw.count} ${this.options.zUnits}`,
224
+ footer: (items) => {
225
+ const bucket = items[0].raw.x;
226
+ const marks = this.options.marks.filter(([b, _]) => b == bucket);
227
+ return marks.map(
228
+ ([b, msg]) => `${this.options.markLabel}: ${msg}`
229
+ );
230
+ },
231
+ },
232
+ },
233
+ },
234
+ };
235
+ }
236
+ }
@@ -102,22 +102,8 @@ div.interval-slider {
102
102
  float: left;
103
103
  }
104
104
 
105
- #realtime-legend,
106
- #history-legend {
107
- text-align: right;
108
- float: left;
109
- }
110
- #realtime-legend .timestamp,
111
- #history-legend .timestamp {
112
- text-align: left;
113
- }
114
- #realtime-legend .line,
115
- #history-legend .line {
116
- margin: 0 20px 0 0;
117
- }
118
- #realtime-legend .swatch,
119
- #history-legend .swatch {
120
- margin: 0 0 0 8px;
105
+ #realtime-legend {
106
+ justify-content: start;
121
107
  }
122
108
 
123
109
  /* Beacon
@@ -165,78 +151,3 @@ div.interval-slider {
165
151
  padding-left: 5px;
166
152
  }
167
153
  }
168
-
169
- /* Rickshaw */
170
-
171
- .rickshaw_graph .detail .x_label.left {
172
- right: 0
173
- }
174
- .rickshaw_graph .detail .x_label.right {
175
- left: 0
176
- }
177
- .rickshaw_graph .detail .item.left {
178
- right: 0
179
- }
180
- .rickshaw_graph .detail .item.right {
181
- left: 0
182
- }
183
- .rickshaw_graph .detail .item.left:after {
184
- left: 0;
185
- right: -5px;
186
- border-right-color: unset;
187
- border-left-color: rgba(0, 0, 0, .8);
188
- border-right-width: 0;
189
- border-left-width: unset;
190
- }
191
- .rickshaw_graph .detail .item.right:after {
192
- right: 0;
193
- left: -5px;
194
- border-left-color: unset;
195
- border-right-color: rgba(0, 0, 0, .8);
196
- border-left-width: 0;
197
- border-right-width: unset;
198
- }
199
- .rickshaw_graph .detail .dot {
200
- margin-right: -3px;
201
- margin-left: unset;
202
- }
203
- .rickshaw_graph .x_tick {
204
- border-left: unset;
205
- border-right: 1px dotted rgba(0, 0, 0, .2);
206
- }
207
- .rickshaw_graph .x_tick .title {
208
- margin-right: 3px;
209
- margin-left: unset;
210
- }
211
- .rickshaw_annotation_timeline .annotation {
212
- margin-right: -2px;
213
- margin-left: unset;
214
- }
215
- .rickshaw_graph .annotation_line {
216
- border-right: 2px solid rgba(0, 0, 0, .3);
217
- border-left: unset;
218
- }
219
- .rickshaw_annotation_timeline .annotation .content {
220
- left: unset;
221
- right: -11px;
222
- }
223
- .rickshaw_graph .x_tick.glow .title,
224
- .rickshaw_graph .y_ticks.glow text {
225
- text-shadow: 1px 1px 0 rgba(255, 255, 255, .1), -1px -1px 0 rgba(255, 255, 255, .1), -1px 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1), 0 -1px 0 rgba(255, 255, 255, .1), -1px 0 0 rgba(255, 255, 255, .1), 1px 0 0 rgba(255, 255, 255, .1), 1px -1px 0 rgba(255, 255, 255, .1)
226
- }
227
- .rickshaw_graph .x_tick.inverse .title,
228
- .rickshaw_graph .y_ticks.inverse text {
229
- text-shadow: 1px 1px 0 rgba(0, 0, 0, .8), -1px -1px 0 rgba(0, 0, 0, .8), -1px 1px 0 rgba(0, 0, 0, .8), 0 1px 0 rgba(0, 0, 0, .8), 0 -1px 0 rgba(0, 0, 0, .8), -1px 0 0 rgba(0, 0, 0, .8), 1px 0 0 rgba(0, 0, 0, .8), 1px -1px 0 rgba(0, 0, 0, .8)
230
- }
231
- .rickshaw_legend .line {
232
- padding-left: 15px;
233
- padding-right: unset;
234
- }
235
- .rickshaw_legend .line .swatch {
236
- margin-left: 3px;
237
- margin-right: unset;
238
- }
239
- .rickshaw_legend .action {
240
- margin-left: .2em;
241
- margin-right: unset;
242
- }