sidekiq 6.3.1 → 7.0.7

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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +205 -11
  3. data/LICENSE.txt +9 -0
  4. data/README.md +45 -32
  5. data/bin/sidekiq +4 -9
  6. data/bin/sidekiqload +189 -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 +308 -188
  13. data/lib/sidekiq/capsule.rb +127 -0
  14. data/lib/sidekiq/cli.rb +85 -80
  15. data/lib/sidekiq/client.rb +74 -81
  16. data/lib/sidekiq/{util.rb → component.rb} +13 -40
  17. data/lib/sidekiq/config.rb +270 -0
  18. data/lib/sidekiq/deploy.rb +62 -0
  19. data/lib/sidekiq/embedded.rb +61 -0
  20. data/lib/sidekiq/fetch.rb +23 -24
  21. data/lib/sidekiq/job.rb +375 -10
  22. data/lib/sidekiq/job_logger.rb +16 -28
  23. data/lib/sidekiq/job_retry.rb +81 -57
  24. data/lib/sidekiq/job_util.rb +105 -0
  25. data/lib/sidekiq/launcher.rb +103 -95
  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 +17 -13
  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 +12 -10
  39. data/lib/sidekiq/redis_client_adapter.rb +115 -0
  40. data/lib/sidekiq/redis_connection.rb +13 -82
  41. data/lib/sidekiq/ring_buffer.rb +29 -0
  42. data/lib/sidekiq/scheduled.rb +75 -37
  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 +45 -11
  49. data/lib/sidekiq/web/csrf_protection.rb +3 -3
  50. data/lib/sidekiq/web/helpers.rb +35 -21
  51. data/lib/sidekiq/web.rb +10 -17
  52. data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
  53. data/lib/sidekiq.rb +85 -202
  54. data/sidekiq.gemspec +20 -10
  55. data/web/assets/javascripts/application.js +76 -26
  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 +3 -240
  61. data/web/assets/javascripts/metrics.js +264 -0
  62. data/web/assets/stylesheets/application-dark.css +17 -17
  63. data/web/assets/stylesheets/application-rtl.css +2 -91
  64. data/web/assets/stylesheets/application.css +69 -302
  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 +67 -67
  74. data/web/locales/he.yml +65 -64
  75. data/web/locales/hi.yml +59 -59
  76. data/web/locales/it.yml +53 -53
  77. data/web/locales/ja.yml +73 -68
  78. data/web/locales/ko.yml +52 -52
  79. data/web/locales/lt.yml +66 -66
  80. data/web/locales/nb.yml +61 -61
  81. data/web/locales/nl.yml +52 -52
  82. data/web/locales/pl.yml +45 -45
  83. data/web/locales/pt-br.yml +63 -55
  84. data/web/locales/pt.yml +51 -51
  85. data/web/locales/ru.yml +67 -66
  86. data/web/locales/sv.yml +53 -53
  87. data/web/locales/ta.yml +60 -60
  88. data/web/locales/uk.yml +62 -61
  89. data/web/locales/ur.yml +64 -64
  90. data/web/locales/vi.yml +67 -67
  91. data/web/locales/zh-cn.yml +43 -16
  92. data/web/locales/zh-tw.yml +42 -8
  93. data/web/views/_footer.erb +5 -2
  94. data/web/views/_job_info.erb +18 -2
  95. data/web/views/_metrics_period_select.erb +12 -0
  96. data/web/views/_nav.erb +1 -1
  97. data/web/views/_paging.erb +2 -0
  98. data/web/views/_poll_link.erb +1 -1
  99. data/web/views/_summary.erb +1 -1
  100. data/web/views/busy.erb +42 -26
  101. data/web/views/dashboard.erb +36 -4
  102. data/web/views/metrics.erb +82 -0
  103. data/web/views/metrics_for_job.erb +71 -0
  104. data/web/views/morgue.erb +5 -9
  105. data/web/views/queue.erb +15 -15
  106. data/web/views/queues.erb +3 -1
  107. data/web/views/retries.erb +5 -9
  108. data/web/views/scheduled.erb +12 -13
  109. metadata +68 -32
  110. data/LICENSE +0 -9
  111. data/lib/generators/sidekiq/worker_generator.rb +0 -57
  112. data/lib/sidekiq/delay.rb +0 -41
  113. data/lib/sidekiq/exception_handler.rb +0 -27
  114. data/lib/sidekiq/extensions/action_mailer.rb +0 -48
  115. data/lib/sidekiq/extensions/active_record.rb +0 -43
  116. data/lib/sidekiq/extensions/class_methods.rb +0 -43
  117. data/lib/sidekiq/extensions/generic_proxy.rb +0 -33
  118. data/lib/sidekiq/worker.rb +0 -311
@@ -0,0 +1,264 @@
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
+ const countBuckets = this.options.labels.length / 60;
8
+ this.labelBuckets = this.options.labels.reduce((acc, label, index) => {
9
+ const bucket = Math.floor(index / countBuckets);
10
+ acc[bucket] = acc[bucket] || [];
11
+ acc[bucket].push(label);
12
+ return acc;
13
+ }, []);
14
+
15
+ this.init();
16
+ }
17
+
18
+ get datasets() {
19
+ return Object.entries(this.options.series)
20
+ .filter(([kls, _]) => this.visibleKls.includes(kls))
21
+ .map(([kls, _]) => this.buildDataset(kls));
22
+ }
23
+
24
+ get metric() {
25
+ return this._metric || this.options.initialMetric;
26
+ }
27
+
28
+ set metric(m) {
29
+ this._metric = m;
30
+ }
31
+
32
+ registerSwatch(id) {
33
+ const el = document.getElementById(id);
34
+ el.addEventListener("change", () => this.toggleKls(el.value, el.checked));
35
+ this.swatches[el.value] = el;
36
+ this.updateSwatch(el.value, el.checked);
37
+ }
38
+
39
+ updateSwatch(kls, checked) {
40
+ const el = this.swatches[kls];
41
+ el.checked = checked;
42
+ el.style.color = this.colors.assignments[kls] || "";
43
+ }
44
+
45
+ toggleKls(kls, visible) {
46
+ if (visible) {
47
+ this.chart.data.datasets.push(this.buildDataset(kls));
48
+ } else {
49
+ const i = this.chart.data.datasets.findIndex((ds) => ds.label == kls);
50
+ this.colors.checkIn(kls);
51
+ this.chart.data.datasets.splice(i, 1);
52
+ }
53
+
54
+ this.updateSwatch(kls, visible);
55
+ this.update();
56
+ }
57
+
58
+ buildDataset(kls) {
59
+ const color = this.colors.checkOut(kls);
60
+
61
+ return {
62
+ label: kls,
63
+ data: this.buildSeries(kls),
64
+ borderColor: color,
65
+ backgroundColor: color,
66
+ borderWidth: 2,
67
+ pointRadius: 2,
68
+ };
69
+ }
70
+
71
+ buildSeries(kls) {
72
+ // `series` is an object that maps labels to counts => { "20:15" => 2, "20:16" => 3, ... }
73
+ const series = this.options.series[kls];
74
+ return this.labelBuckets.reduce((acc, labels) => {
75
+ const bucketValues = labels.map(label => series[label]).filter(v => v);
76
+ if (bucketValues.length > 0) {
77
+ // Sum up the values for each bucket that has data.
78
+ // The new label is the bucket's first label, its start time.
79
+ acc[labels[0]] = bucketValues.reduce((a, b) => a + b, 0);
80
+ }
81
+ return acc;
82
+ }, {});
83
+ }
84
+
85
+ buildTooltipTitle(items) {
86
+ const [first, ...rest] = this.labelBuckets.find((labels) => labels[0] === items[0].label);
87
+ const title = [first, rest[rest.length - 1]].filter(v => v).join(" - ");
88
+ return `${title} UTC`
89
+ }
90
+
91
+ get chartOptions() {
92
+ return {
93
+ ...super.chartOptions,
94
+ aspectRatio: 4,
95
+ scales: {
96
+ ...super.chartOptions.scales,
97
+ y: {
98
+ ...super.chartOptions.scales.y,
99
+ beginAtZero: true,
100
+ title: {
101
+ text: this.options.yLabel,
102
+ display: true,
103
+ },
104
+ },
105
+ },
106
+ plugins: {
107
+ ...super.chartOptions.plugins,
108
+ tooltip: {
109
+ ...super.chartOptions.plugins.tooltip,
110
+ callbacks: {
111
+ title: (items) => this.buildTooltipTitle(items),
112
+ label: (item) =>
113
+ `${item.dataset.label}: ${item.parsed.y.toFixed(1)} ` +
114
+ `${this.options.units}`,
115
+ footer: (items) => {
116
+ const bucket = items[0].label;
117
+ const marks = this.options.marks.filter(([b, _]) => b == bucket);
118
+ return marks.map(
119
+ ([b, msg]) => `${this.options.markLabel}: ${msg}`
120
+ );
121
+ },
122
+ },
123
+ },
124
+ },
125
+ };
126
+ }
127
+ }
128
+
129
+ class HistTotalsChart extends BaseChart {
130
+ constructor(el, options) {
131
+ super(el, { ...options, chartType: "bar" });
132
+ this.init();
133
+ }
134
+
135
+ get datasets() {
136
+ return [
137
+ {
138
+ data: this.options.series,
139
+ backgroundColor: this.colors.primary,
140
+ borderWidth: 0,
141
+ },
142
+ ];
143
+ }
144
+
145
+ get chartOptions() {
146
+ return {
147
+ ...super.chartOptions,
148
+ aspectRatio: 6,
149
+ scales: {
150
+ ...super.chartOptions.scales,
151
+ y: {
152
+ ...super.chartOptions.scales.y,
153
+ beginAtZero: true,
154
+ title: {
155
+ text: this.options.yLabel,
156
+ display: true,
157
+ },
158
+ },
159
+ x: {
160
+ ...super.chartOptions.scales.x,
161
+ title: {
162
+ text: this.options.xLabel,
163
+ display: true,
164
+ },
165
+ },
166
+ },
167
+ plugins: {
168
+ ...super.chartOptions.plugins,
169
+ tooltip: {
170
+ ...super.chartOptions.plugins.tooltip,
171
+ callbacks: {
172
+ label: (item) => `${item.parsed.y} ${this.options.units}`,
173
+ },
174
+ },
175
+ },
176
+ };
177
+ }
178
+ }
179
+
180
+ class HistBubbleChart extends BaseChart {
181
+ constructor(el, options) {
182
+ super(el, { ...options, chartType: "bubble" });
183
+ this.init();
184
+ }
185
+
186
+ get datasets() {
187
+ const data = [];
188
+ let maxCount = 0;
189
+
190
+ Object.entries(this.options.hist).forEach(([bucket, hist]) => {
191
+ hist.forEach((count, histBucket) => {
192
+ if (count > 0) {
193
+ // histogram data is ordered fastest to slowest, but this.histIntervals is
194
+ // slowest to fastest (so it displays correctly on the chart).
195
+ const index = this.options.histIntervals.length - 1 - histBucket;
196
+
197
+ data.push({
198
+ x: bucket,
199
+ y: this.options.histIntervals[index] / 1000,
200
+ count: count,
201
+ });
202
+
203
+ if (count > maxCount) maxCount = count;
204
+ }
205
+ });
206
+ });
207
+
208
+ // Chart.js will not calculate the bubble size. We have to do that.
209
+ const maxRadius = this.el.offsetWidth / this.options.labels.length;
210
+ const minRadius = 1;
211
+ const multiplier = (maxRadius / maxCount) * 1.5;
212
+ data.forEach((entry) => {
213
+ entry.r = entry.count * multiplier + minRadius;
214
+ });
215
+
216
+ return [
217
+ {
218
+ data: data,
219
+ backgroundColor: this.colors.primary,
220
+ borderColor: this.colors.primary,
221
+ },
222
+ ];
223
+ }
224
+
225
+ get chartOptions() {
226
+ return {
227
+ ...super.chartOptions,
228
+ aspectRatio: 3,
229
+ scales: {
230
+ ...super.chartOptions.scales,
231
+ x: {
232
+ ...super.chartOptions.scales.x,
233
+ type: "category",
234
+ labels: this.options.labels,
235
+ },
236
+ y: {
237
+ ...super.chartOptions.scales.y,
238
+ title: {
239
+ text: this.options.yLabel,
240
+ display: true,
241
+ },
242
+ },
243
+ },
244
+ plugins: {
245
+ ...super.chartOptions.plugins,
246
+ tooltip: {
247
+ ...super.chartOptions.plugins.tooltip,
248
+ callbacks: {
249
+ title: (items) => `${items[0].raw.x} UTC`,
250
+ label: (item) =>
251
+ `${item.parsed.y} ${this.options.yUnits}: ${item.raw.count} ${this.options.zUnits}`,
252
+ footer: (items) => {
253
+ const bucket = items[0].raw.x;
254
+ const marks = this.options.marks.filter(([b, _]) => b == bucket);
255
+ return marks.map(
256
+ ([b, msg]) => `${this.options.markLabel}: ${msg}`
257
+ );
258
+ },
259
+ },
260
+ },
261
+ },
262
+ };
263
+ }
264
+ }
@@ -1,6 +1,6 @@
1
1
  html, body {
2
- background-color: #333 !important;
3
- color: #ddd;
2
+ background-color: #171717 !important;
3
+ color: #DEDEDE;
4
4
  }
5
5
 
6
6
  a,
@@ -30,15 +30,15 @@ span.current-interval,
30
30
 
31
31
  .navbar-inverse {
32
32
  background-color: #222;
33
- border-color: #555;
33
+ border-color: #444;
34
34
  }
35
35
 
36
36
  table {
37
- background-color: #282828;
37
+ background-color: #1D1D1D;
38
38
  }
39
39
 
40
40
  .table-striped > tbody > tr:nth-of-type(odd) {
41
- background-color: #333;
41
+ background-color: #2E2E2E;
42
42
  }
43
43
 
44
44
  .table-bordered,
@@ -48,7 +48,7 @@ table {
48
48
  .table-bordered > tfoot > tr > th,
49
49
  .table-bordered > thead > tr > td,
50
50
  .table-bordered > thead > tr > th {
51
- border: 1px solid #555;
51
+ border: 1px solid #444;
52
52
  }
53
53
 
54
54
  .table-hover > tbody > tr:hover {
@@ -72,9 +72,11 @@ table {
72
72
  background-color: #31708f;
73
73
  }
74
74
 
75
- a:link,
76
- a:active,
77
- a:hover {
75
+ .alert-warning {
76
+ background-color: #c47612;
77
+ }
78
+
79
+ a:link, a:active, a:hover, a:visited {
78
80
  color: #ddd;
79
81
  }
80
82
 
@@ -85,15 +87,13 @@ input {
85
87
  }
86
88
 
87
89
  .summary_bar .summary {
88
- background-color: #222;
89
- border: 1px solid #555;
90
-
91
- box-shadow: 0 0 5px rgba(255, 255, 255, .5);
90
+ background-color: #232323;
91
+ border: 1px solid #444;
92
92
  }
93
93
 
94
94
  .navbar-default {
95
- background-color: #222;
96
- border-color: #555;
95
+ background-color: #0F0F0F;
96
+ border-color: #444;
97
97
  }
98
98
 
99
99
  .navbar-default .navbar-nav > .active > a,
@@ -112,7 +112,7 @@ input {
112
112
  .pagination > li > span {
113
113
  color: #ddd;
114
114
  background-color: #333;
115
- border-color: #555;
115
+ border-color: #444;
116
116
  }
117
117
  .pagination > .disabled > a,
118
118
  .pagination > .disabled > a:focus,
@@ -122,7 +122,7 @@ input {
122
122
  .pagination > .disabled > span:hover {
123
123
  color: #ddd;
124
124
  background-color: #333;
125
- border-color: #555;
125
+ border-color: #444;
126
126
  }
127
127
 
128
128
  .stat {
@@ -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
- }