sidekiq 5.1.1 → 5.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.
- checksums.yaml +4 -4
- data/Changes.md +11 -0
- data/Ent-Changes.md +6 -0
- data/LICENSE +1 -1
- data/Pro-Changes.md +13 -0
- data/lib/sidekiq.rb +2 -3
- data/lib/sidekiq/api.rb +17 -18
- data/lib/sidekiq/cli.rb +4 -3
- data/lib/sidekiq/client.rb +27 -27
- data/lib/sidekiq/delay.rb +1 -0
- data/lib/sidekiq/fetch.rb +1 -1
- data/lib/sidekiq/job_logger.rb +2 -1
- data/lib/sidekiq/job_retry.rb +7 -2
- data/lib/sidekiq/launcher.rb +4 -5
- data/lib/sidekiq/logging.rb +3 -3
- data/lib/sidekiq/manager.rb +0 -1
- data/lib/sidekiq/middleware/server/active_record.rb +2 -1
- data/lib/sidekiq/processor.rb +3 -3
- data/lib/sidekiq/rails.rb +4 -9
- data/lib/sidekiq/redis_connection.rb +10 -2
- data/lib/sidekiq/scheduled.rb +1 -1
- data/lib/sidekiq/util.rb +1 -1
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web.rb +4 -4
- data/lib/sidekiq/web/action.rb +1 -1
- data/lib/sidekiq/web/application.rb +2 -2
- data/lib/sidekiq/web/helpers.rb +1 -1
- data/lib/sidekiq/web/router.rb +10 -10
- data/lib/sidekiq/worker.rb +7 -7
- data/web/views/_footer.erb +3 -0
- metadata +2 -3
- data/lib/sidekiq/middleware/server/active_record_cache.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fbe302468cb06bdf841f96cbf31fe9d30ddfc1e
|
4
|
+
data.tar.gz: ffb44c96f5d912c067b0d09e00c517742a34dbe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 607b662f70cae01418e2d977e269cb093eec29fccd5140be91c6f6ce8d63544b70ce52361e18ccf8ab46f1bcf0d8e5d556c433ac1ccb1bb2c0a4b31d4848cb70
|
7
|
+
data.tar.gz: 9552e2fa7e2a4f443e370cad0d9e55d546b1dab0ff04748c054c51de912f139b219304c808ed74c127ce3b9b22ae471011219391f67e7223321b96a0e5f333e6
|
data/Changes.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
|
4
4
|
|
5
|
+
5.1.2
|
6
|
+
-----------
|
7
|
+
|
8
|
+
- Add link to docs in Web UI footer
|
9
|
+
- Fix crash on Ctrl-C in Windows [#3775, Bernica]
|
10
|
+
- Remove `freeze` calls on String constants. This is superfluous with Ruby
|
11
|
+
2.3+ and `frozen_string_literal: true`. [#3759]
|
12
|
+
- Fix use of AR middleware outside of Rails [#3787]
|
13
|
+
- Sidekiq::Worker `sidekiq_retry_in` block can now return nil or 0 to use
|
14
|
+
the default backoff delay [#3796, dsalahutdinov]
|
15
|
+
|
5
16
|
5.1.1
|
6
17
|
-----------
|
7
18
|
|
data/Ent-Changes.md
CHANGED
@@ -4,6 +4,12 @@
|
|
4
4
|
|
5
5
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
6
6
|
|
7
|
+
HEAD
|
8
|
+
-------------
|
9
|
+
|
10
|
+
- Fix Lua error in concurrent rate limiter under heavy contention
|
11
|
+
- Remove superfluous `freeze` calls on Strings [#3759]
|
12
|
+
|
7
13
|
1.7.0
|
8
14
|
-------------
|
9
15
|
|
data/LICENSE
CHANGED
@@ -5,5 +5,5 @@ the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
|
|
5
5
|
for license text.
|
6
6
|
|
7
7
|
Sidekiq Pro has a commercial-friendly license allowing private forks
|
8
|
-
and modifications of Sidekiq. Please see
|
8
|
+
and modifications of Sidekiq. Please see https://sidekiq.org/products/pro.html for
|
9
9
|
more detail. You can find the commercial license terms in COMM-LICENSE.
|
data/Pro-Changes.md
CHANGED
@@ -4,6 +4,19 @@
|
|
4
4
|
|
5
5
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
6
6
|
|
7
|
+
HEAD
|
8
|
+
---------
|
9
|
+
|
10
|
+
- Remove super\_fetch edge case leading to an unnecessary `sleep(1)`
|
11
|
+
call and resulting latency [#3790]
|
12
|
+
- Fix possible bad statsd metric call on super\_fetch startup
|
13
|
+
- Remove superfluous `freeze` calls on Strings [#3759]
|
14
|
+
|
15
|
+
4.0.1
|
16
|
+
---------
|
17
|
+
|
18
|
+
- Fix incompatibility with the statsd-ruby gem [#3740]
|
19
|
+
|
7
20
|
4.0.0
|
8
21
|
---------
|
9
22
|
|
data/lib/sidekiq.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
require 'sidekiq/version'
|
4
3
|
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.2.2." if RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.2.2'
|
@@ -12,7 +11,7 @@ require 'sidekiq/delay'
|
|
12
11
|
require 'json'
|
13
12
|
|
14
13
|
module Sidekiq
|
15
|
-
NAME = 'Sidekiq'
|
14
|
+
NAME = 'Sidekiq'
|
16
15
|
LICENSE = 'See LICENSE and the LGPL-3.0 for licensing details.'
|
17
16
|
|
18
17
|
DEFAULTS = {
|
@@ -48,7 +47,7 @@ module Sidekiq
|
|
48
47
|
"connected_clients" => "9999",
|
49
48
|
"used_memory_human" => "9P",
|
50
49
|
"used_memory_peak_human" => "9P"
|
51
|
-
}
|
50
|
+
}
|
52
51
|
|
53
52
|
def self.❨╯°□°❩╯︵┻━┻
|
54
53
|
puts "Calm down, yo."
|
data/lib/sidekiq/api.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
require 'sidekiq'
|
4
3
|
|
@@ -51,21 +50,21 @@ module Sidekiq
|
|
51
50
|
def fetch_stats!
|
52
51
|
pipe1_res = Sidekiq.redis do |conn|
|
53
52
|
conn.pipelined do
|
54
|
-
conn.get('stat:processed'
|
55
|
-
conn.get('stat:failed'
|
56
|
-
conn.zcard('schedule'
|
57
|
-
conn.zcard('retry'
|
58
|
-
conn.zcard('dead'
|
59
|
-
conn.scard('processes'
|
60
|
-
conn.lrange('queue:default'
|
61
|
-
conn.smembers('processes'
|
62
|
-
conn.smembers('queues'
|
53
|
+
conn.get('stat:processed')
|
54
|
+
conn.get('stat:failed')
|
55
|
+
conn.zcard('schedule')
|
56
|
+
conn.zcard('retry')
|
57
|
+
conn.zcard('dead')
|
58
|
+
conn.scard('processes')
|
59
|
+
conn.lrange('queue:default', -1, -1)
|
60
|
+
conn.smembers('processes')
|
61
|
+
conn.smembers('queues')
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
pipe2_res = Sidekiq.redis do |conn|
|
67
66
|
conn.pipelined do
|
68
|
-
pipe1_res[7].each {|key| conn.hget(key, 'busy'
|
67
|
+
pipe1_res[7].each {|key| conn.hget(key, 'busy') }
|
69
68
|
pipe1_res[8].each {|queue| conn.llen("queue:#{queue}") }
|
70
69
|
end
|
71
70
|
end
|
@@ -77,7 +76,7 @@ module Sidekiq
|
|
77
76
|
default_queue_latency = if (entry = pipe1_res[6].first)
|
78
77
|
job = Sidekiq.load_json(entry) rescue {}
|
79
78
|
now = Time.now.to_f
|
80
|
-
thence = job['enqueued_at'
|
79
|
+
thence = job['enqueued_at'] || now
|
81
80
|
now - thence
|
82
81
|
else
|
83
82
|
0
|
@@ -119,7 +118,7 @@ module Sidekiq
|
|
119
118
|
class Queues
|
120
119
|
def lengths
|
121
120
|
Sidekiq.redis do |conn|
|
122
|
-
queues = conn.smembers('queues'
|
121
|
+
queues = conn.smembers('queues')
|
123
122
|
|
124
123
|
lengths = conn.pipelined do
|
125
124
|
queues.each do |queue|
|
@@ -163,7 +162,7 @@ module Sidekiq
|
|
163
162
|
|
164
163
|
while i < @days_previous
|
165
164
|
date = @start_date - i
|
166
|
-
datestr = date.strftime("%Y-%m-%d"
|
165
|
+
datestr = date.strftime("%Y-%m-%d")
|
167
166
|
keys << "stat:#{stat}:#{datestr}"
|
168
167
|
dates << datestr
|
169
168
|
i += 1
|
@@ -204,7 +203,7 @@ module Sidekiq
|
|
204
203
|
# Return all known queues within Redis.
|
205
204
|
#
|
206
205
|
def self.all
|
207
|
-
Sidekiq.redis { |c| c.smembers('queues'
|
206
|
+
Sidekiq.redis { |c| c.smembers('queues') }.sort.map { |q| Sidekiq::Queue.new(q) }
|
208
207
|
end
|
209
208
|
|
210
209
|
attr_reader :name
|
@@ -273,7 +272,7 @@ module Sidekiq
|
|
273
272
|
Sidekiq.redis do |conn|
|
274
273
|
conn.multi do
|
275
274
|
conn.del(@rname)
|
276
|
-
conn.srem("queues"
|
275
|
+
conn.srem("queues", name)
|
277
276
|
end
|
278
277
|
end
|
279
278
|
end
|
@@ -349,9 +348,9 @@ module Sidekiq
|
|
349
348
|
job_args
|
350
349
|
end
|
351
350
|
else
|
352
|
-
if self['encrypt'
|
351
|
+
if self['encrypt']
|
353
352
|
# no point in showing 150+ bytes of random garbage
|
354
|
-
args[-1] = '[encrypted data]'
|
353
|
+
args[-1] = '[encrypted data]'
|
355
354
|
end
|
356
355
|
args
|
357
356
|
end
|
data/lib/sidekiq/cli.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
$stdout.sync = true
|
4
3
|
|
@@ -17,7 +16,7 @@ module Sidekiq
|
|
17
16
|
include Singleton unless $TESTING
|
18
17
|
|
19
18
|
PROCTITLES = [
|
20
|
-
proc { 'sidekiq'
|
19
|
+
proc { 'sidekiq' },
|
21
20
|
proc { Sidekiq::VERSION },
|
22
21
|
proc { |me, data| data['tag'] },
|
23
22
|
proc { |me, data| "[#{Processor::WORKER_STATE.size} of #{data['concurrency']} busy]" },
|
@@ -65,7 +64,7 @@ module Sidekiq
|
|
65
64
|
sigs.each do |sig|
|
66
65
|
begin
|
67
66
|
trap sig do
|
68
|
-
self_write.
|
67
|
+
self_write.write("#{sig}\n")
|
69
68
|
end
|
70
69
|
rescue ArgumentError
|
71
70
|
puts "Signal #{sig} not supported"
|
@@ -330,6 +329,8 @@ module Sidekiq
|
|
330
329
|
opts[:tag] = arg
|
331
330
|
end
|
332
331
|
|
332
|
+
# this index remains here for backwards compatibility but none of the Sidekiq
|
333
|
+
# family use this value anymore. it was used by Pro's original reliable_fetch.
|
333
334
|
o.on '-i', '--index INT', "unique process index on this machine" do |arg|
|
334
335
|
opts[:index] = Integer(arg.match(/\d+/)[0])
|
335
336
|
end
|
data/lib/sidekiq/client.rb
CHANGED
@@ -68,11 +68,11 @@ module Sidekiq
|
|
68
68
|
#
|
69
69
|
def push(item)
|
70
70
|
normed = normalize_item(item)
|
71
|
-
payload = process_single(item['class'
|
71
|
+
payload = process_single(item['class'], normed)
|
72
72
|
|
73
73
|
if payload
|
74
74
|
raw_push([payload])
|
75
|
-
payload['jid'
|
75
|
+
payload['jid']
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -89,19 +89,19 @@ module Sidekiq
|
|
89
89
|
# Returns an array of the of pushed jobs' jids. The number of jobs pushed can be less
|
90
90
|
# than the number given if the middleware stopped processing for one or more jobs.
|
91
91
|
def push_bulk(items)
|
92
|
-
arg = items['args'
|
92
|
+
arg = items['args'].first
|
93
93
|
return [] unless arg # no jobs to push
|
94
94
|
raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" if !arg.is_a?(Array)
|
95
95
|
|
96
96
|
normed = normalize_item(items)
|
97
|
-
payloads = items['args'
|
98
|
-
copy = normed.merge('args'
|
99
|
-
result = process_single(items['class'
|
97
|
+
payloads = items['args'].map do |args|
|
98
|
+
copy = normed.merge('args' => args, 'jid' => SecureRandom.hex(12), 'enqueued_at' => Time.now.to_f)
|
99
|
+
result = process_single(items['class'], copy)
|
100
100
|
result ? result : nil
|
101
101
|
end.compact
|
102
102
|
|
103
103
|
raw_push(payloads) if !payloads.empty?
|
104
|
-
payloads.collect { |payload| payload['jid'
|
104
|
+
payloads.collect { |payload| payload['jid'] }
|
105
105
|
end
|
106
106
|
|
107
107
|
# Allows sharding of jobs across any number of Redis instances. All jobs
|
@@ -144,14 +144,14 @@ module Sidekiq
|
|
144
144
|
# Messages are enqueued to the 'default' queue.
|
145
145
|
#
|
146
146
|
def enqueue(klass, *args)
|
147
|
-
klass.client_push('class'
|
147
|
+
klass.client_push('class' => klass, 'args' => args)
|
148
148
|
end
|
149
149
|
|
150
150
|
# Example usage:
|
151
151
|
# Sidekiq::Client.enqueue_to(:queue_name, MyWorker, 'foo', 1, :bat => 'bar')
|
152
152
|
#
|
153
153
|
def enqueue_to(queue, klass, *args)
|
154
|
-
klass.client_push('queue'
|
154
|
+
klass.client_push('queue' => queue, 'class' => klass, 'args' => args)
|
155
155
|
end
|
156
156
|
|
157
157
|
# Example usage:
|
@@ -162,8 +162,8 @@ module Sidekiq
|
|
162
162
|
now = Time.now.to_f
|
163
163
|
ts = (int < 1_000_000_000 ? now + int : int)
|
164
164
|
|
165
|
-
item = { 'class'
|
166
|
-
item.delete('at'
|
165
|
+
item = { 'class' => klass, 'args' => args, 'at' => ts, 'queue' => queue }
|
166
|
+
item.delete('at') if ts <= now
|
167
167
|
|
168
168
|
klass.client_push(item)
|
169
169
|
end
|
@@ -188,25 +188,25 @@ module Sidekiq
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def atomic_push(conn, payloads)
|
191
|
-
if payloads.first['at'
|
192
|
-
conn.zadd('schedule'
|
193
|
-
at = hash.delete('at'
|
191
|
+
if payloads.first['at']
|
192
|
+
conn.zadd('schedule', payloads.map do |hash|
|
193
|
+
at = hash.delete('at').to_s
|
194
194
|
[at, Sidekiq.dump_json(hash)]
|
195
195
|
end)
|
196
196
|
else
|
197
|
-
q = payloads.first['queue'
|
197
|
+
q = payloads.first['queue']
|
198
198
|
now = Time.now.to_f
|
199
199
|
to_push = payloads.map do |entry|
|
200
|
-
entry['enqueued_at'
|
200
|
+
entry['enqueued_at'] = now
|
201
201
|
Sidekiq.dump_json(entry)
|
202
202
|
end
|
203
|
-
conn.sadd('queues'
|
203
|
+
conn.sadd('queues', q)
|
204
204
|
conn.lpush("queue:#{q}", to_push)
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
208
|
def process_single(worker_class, item)
|
209
|
-
queue = item['queue'
|
209
|
+
queue = item['queue']
|
210
210
|
|
211
211
|
middleware.invoke(worker_class, item, queue, @redis_pool) do
|
212
212
|
item
|
@@ -214,25 +214,25 @@ module Sidekiq
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def normalize_item(item)
|
217
|
-
raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.has_key?('class'
|
217
|
+
raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.has_key?('class') && item.has_key?('args')
|
218
218
|
raise(ArgumentError, "Job args must be an Array") unless item['args'].is_a?(Array)
|
219
|
-
raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item['class'
|
220
|
-
raise(ArgumentError, "Job 'at' must be a Numeric timestamp") if item.has_key?('at'
|
219
|
+
raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item['class'].is_a?(Class) || item['class'].is_a?(String)
|
220
|
+
raise(ArgumentError, "Job 'at' must be a Numeric timestamp") if item.has_key?('at') && !item['at'].is_a?(Numeric)
|
221
221
|
#raise(ArgumentError, "Arguments must be native JSON types, see https://github.com/mperham/sidekiq/wiki/Best-Practices") unless JSON.load(JSON.dump(item['args'])) == item['args']
|
222
222
|
|
223
|
-
normalized_hash(item['class'
|
223
|
+
normalized_hash(item['class'])
|
224
224
|
.each{ |key, value| item[key] = value if item[key].nil? }
|
225
225
|
|
226
|
-
item['class'
|
227
|
-
item['queue'
|
228
|
-
item['jid'
|
229
|
-
item['created_at'
|
226
|
+
item['class'] = item['class'].to_s
|
227
|
+
item['queue'] = item['queue'].to_s
|
228
|
+
item['jid'] ||= SecureRandom.hex(12)
|
229
|
+
item['created_at'] ||= Time.now.to_f
|
230
230
|
item
|
231
231
|
end
|
232
232
|
|
233
233
|
def normalized_hash(item_class)
|
234
234
|
if item_class.is_a?(Class)
|
235
|
-
raise(ArgumentError, "Message must include a Sidekiq::Worker class, not class name: #{item_class.ancestors.inspect}") if !item_class.respond_to?('get_sidekiq_options'
|
235
|
+
raise(ArgumentError, "Message must include a Sidekiq::Worker class, not class name: #{item_class.ancestors.inspect}") if !item_class.respond_to?('get_sidekiq_options')
|
236
236
|
item_class.get_sidekiq_options
|
237
237
|
else
|
238
238
|
Sidekiq.default_worker_options
|
data/lib/sidekiq/delay.rb
CHANGED
data/lib/sidekiq/fetch.rb
CHANGED
data/lib/sidekiq/job_logger.rb
CHANGED
data/lib/sidekiq/job_retry.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'sidekiq/scheduled'
|
2
3
|
require 'sidekiq/api'
|
3
4
|
|
@@ -204,7 +205,11 @@ module Sidekiq
|
|
204
205
|
end
|
205
206
|
|
206
207
|
def delay_for(worker, count, exception)
|
207
|
-
worker && worker.sidekiq_retry_in_block
|
208
|
+
if worker && worker.sidekiq_retry_in_block
|
209
|
+
custom_retry_in = retry_in(worker, count, exception).to_i
|
210
|
+
return custom_retry_in if custom_retry_in > 0
|
211
|
+
end
|
212
|
+
seconds_to_delay(count)
|
208
213
|
end
|
209
214
|
|
210
215
|
# delayed_job uses the same basic formula
|
@@ -214,7 +219,7 @@ module Sidekiq
|
|
214
219
|
|
215
220
|
def retry_in(worker, count, exception)
|
216
221
|
begin
|
217
|
-
worker.sidekiq_retry_in_block.call(count, exception)
|
222
|
+
worker.sidekiq_retry_in_block.call(count, exception)
|
218
223
|
rescue Exception => e
|
219
224
|
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
220
225
|
nil
|
data/lib/sidekiq/launcher.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
require 'sidekiq/manager'
|
4
3
|
require 'sidekiq/fetch'
|
@@ -76,13 +75,13 @@ module Sidekiq
|
|
76
75
|
Processor::FAILURE.update {|curr| fails = curr; 0 }
|
77
76
|
Processor::PROCESSED.update {|curr| procd = curr; 0 }
|
78
77
|
|
79
|
-
workers_key = "#{key}:workers"
|
80
|
-
nowdate = Time.now.utc.strftime("%Y-%m-%d"
|
78
|
+
workers_key = "#{key}:workers"
|
79
|
+
nowdate = Time.now.utc.strftime("%Y-%m-%d")
|
81
80
|
Sidekiq.redis do |conn|
|
82
81
|
conn.multi do
|
83
|
-
conn.incrby("stat:processed"
|
82
|
+
conn.incrby("stat:processed", procd)
|
84
83
|
conn.incrby("stat:processed:#{nowdate}", procd)
|
85
|
-
conn.incrby("stat:failed"
|
84
|
+
conn.incrby("stat:failed", fails)
|
86
85
|
conn.incrby("stat:failed:#{nowdate}", fails)
|
87
86
|
conn.del(workers_key)
|
88
87
|
Processor::WORKER_STATE.each_pair do |tid, hash|
|
data/lib/sidekiq/logging.rb
CHANGED
@@ -33,9 +33,9 @@ module Sidekiq
|
|
33
33
|
def self.job_hash_context(job_hash)
|
34
34
|
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
|
35
35
|
# attribute to expose the underlying thing.
|
36
|
-
klass = job_hash['wrapped'
|
37
|
-
bid = job_hash['bid'
|
38
|
-
"#{klass} JID-#{job_hash['jid'
|
36
|
+
klass = job_hash['wrapped'] || job_hash["class"]
|
37
|
+
bid = job_hash['bid']
|
38
|
+
"#{klass} JID-#{job_hash['jid']}#{" BID-#{bid}" if bid}"
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.with_job_hash_context(job_hash, &block)
|
data/lib/sidekiq/manager.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Sidekiq
|
2
3
|
module Middleware
|
3
4
|
module Server
|
@@ -6,7 +7,7 @@ module Sidekiq
|
|
6
7
|
def initialize
|
7
8
|
# With Rails 5+ we must use the Reloader **always**.
|
8
9
|
# The reloader handles code loading and db connection management.
|
9
|
-
if ::Rails::VERSION::MAJOR >= 5
|
10
|
+
if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 5
|
10
11
|
raise ArgumentError, "Rails 5 no longer needs or uses the ActiveRecord middleware."
|
11
12
|
end
|
12
13
|
end
|
data/lib/sidekiq/processor.rb
CHANGED
@@ -132,9 +132,9 @@ module Sidekiq
|
|
132
132
|
# the Reloader. It handles code loading, db connection management, etc.
|
133
133
|
# Effectively this block denotes a "unit of work" to Rails.
|
134
134
|
@reloader.call do
|
135
|
-
klass = constantize(job_hash['class'
|
135
|
+
klass = constantize(job_hash['class'])
|
136
136
|
worker = klass.new
|
137
|
-
worker.jid = job_hash['jid'
|
137
|
+
worker.jid = job_hash['jid']
|
138
138
|
@retrier.local(worker, pristine, queue) do
|
139
139
|
yield worker
|
140
140
|
end
|
@@ -166,7 +166,7 @@ module Sidekiq
|
|
166
166
|
ack = true
|
167
167
|
dispatch(job_hash, queue) do |worker|
|
168
168
|
Sidekiq.server_middleware.invoke(worker, job_hash, queue) do
|
169
|
-
execute_job(worker, cloned(job_hash['args'
|
169
|
+
execute_job(worker, cloned(job_hash['args']))
|
170
170
|
end
|
171
171
|
end
|
172
172
|
rescue Sidekiq::Shutdown
|
data/lib/sidekiq/rails.rb
CHANGED
@@ -9,15 +9,10 @@ module Sidekiq
|
|
9
9
|
# class block. Definitely before config/environments/*.rb and
|
10
10
|
# config/initializers/*.rb.
|
11
11
|
config.before_configuration do
|
12
|
-
if defined?(::ActiveRecord)
|
12
|
+
if ::Rails::VERSION::MAJOR < 5 && defined?(::ActiveRecord)
|
13
13
|
Sidekiq.server_middleware do |chain|
|
14
|
-
|
15
|
-
|
16
|
-
chain.add Sidekiq::Middleware::Server::ActiveRecord
|
17
|
-
end
|
18
|
-
|
19
|
-
require 'sidekiq/middleware/server/active_record_cache'
|
20
|
-
chain.add Sidekiq::Middleware::Server::ActiveRecordCache
|
14
|
+
require 'sidekiq/middleware/server/active_record'
|
15
|
+
chain.add Sidekiq::Middleware::Server::ActiveRecord
|
21
16
|
end
|
22
17
|
end
|
23
18
|
end
|
@@ -59,4 +54,4 @@ if defined?(::Rails) && ::Rails::VERSION::MAJOR < 4
|
|
59
54
|
$stderr.puts("**************************************************")
|
60
55
|
$stderr.puts("⛔️ WARNING: Sidekiq server is no longer supported by Rails 3.2 - please ensure your server/workers are updated")
|
61
56
|
$stderr.puts("**************************************************")
|
62
|
-
end
|
57
|
+
end
|
@@ -15,7 +15,15 @@ module Sidekiq
|
|
15
15
|
options[:id] = "Sidekiq-#{Sidekiq.server? ? "server" : "client"}-PID-#{$$}" if !options.has_key?(:id)
|
16
16
|
options[:url] ||= determine_redis_provider
|
17
17
|
|
18
|
-
size = options[:size]
|
18
|
+
size = if options[:size]
|
19
|
+
options[:size]
|
20
|
+
elsif Sidekiq.server?
|
21
|
+
Sidekiq.options[:concurrency] + 5
|
22
|
+
elsif ENV['RAILS_MAX_THREADS']
|
23
|
+
Integer(ENV['RAILS_MAX_THREADS'])
|
24
|
+
else
|
25
|
+
5
|
26
|
+
end
|
19
27
|
|
20
28
|
verify_sizing(size, Sidekiq.options[:concurrency]) if Sidekiq.server?
|
21
29
|
|
@@ -70,7 +78,7 @@ module Sidekiq
|
|
70
78
|
opts.delete(:network_timeout)
|
71
79
|
end
|
72
80
|
|
73
|
-
opts[:driver] ||= 'ruby'
|
81
|
+
opts[:driver] ||= 'ruby'
|
74
82
|
|
75
83
|
# Issue #3303, redis-rb will silently retry an operation.
|
76
84
|
# This can lead to duplicate jobs if Sidekiq::Client's LPUSH
|
data/lib/sidekiq/scheduled.rb
CHANGED
@@ -17,7 +17,7 @@ module Sidekiq
|
|
17
17
|
# We need to go through the list one at a time to reduce the risk of something
|
18
18
|
# going wrong between the time jobs are popped from the scheduled queue and when
|
19
19
|
# they are pushed onto a work queue and losing the jobs.
|
20
|
-
while job = conn.zrangebyscore(sorted_set, '-inf'
|
20
|
+
while job = conn.zrangebyscore(sorted_set, '-inf', now, :limit => [0, 1]).first do
|
21
21
|
|
22
22
|
# Pop item off the queue and add it to the work queue. If the job can't be popped from
|
23
23
|
# the queue, it's because another process already popped it so we can move on to the
|
data/lib/sidekiq/util.rb
CHANGED
data/lib/sidekiq/version.rb
CHANGED
data/lib/sidekiq/web.rb
CHANGED
@@ -19,10 +19,10 @@ require 'rack/session/cookie'
|
|
19
19
|
module Sidekiq
|
20
20
|
class Web
|
21
21
|
ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../web")
|
22
|
-
VIEWS = "#{ROOT}/views"
|
23
|
-
LOCALES = ["#{ROOT}/locales"
|
24
|
-
LAYOUT = "#{VIEWS}/layout.erb"
|
25
|
-
ASSETS = "#{ROOT}/assets"
|
22
|
+
VIEWS = "#{ROOT}/views"
|
23
|
+
LOCALES = ["#{ROOT}/locales"]
|
24
|
+
LAYOUT = "#{VIEWS}/layout.erb"
|
25
|
+
ASSETS = "#{ROOT}/assets"
|
26
26
|
|
27
27
|
DEFAULT_TABS = {
|
28
28
|
"Dashboard" => '',
|
data/lib/sidekiq/web/action.rb
CHANGED
@@ -4,8 +4,8 @@ module Sidekiq
|
|
4
4
|
class WebApplication
|
5
5
|
extend WebRouter
|
6
6
|
|
7
|
-
CONTENT_LENGTH = "Content-Length"
|
8
|
-
CONTENT_TYPE = "Content-Type"
|
7
|
+
CONTENT_LENGTH = "Content-Length"
|
8
|
+
CONTENT_TYPE = "Content-Type"
|
9
9
|
REDIS_KEYS = %w(redis_version uptime_in_days connected_clients used_memory_human used_memory_peak_human)
|
10
10
|
|
11
11
|
def initialize(klass)
|
data/lib/sidekiq/web/helpers.rb
CHANGED
@@ -80,7 +80,7 @@ module Sidekiq
|
|
80
80
|
|
81
81
|
# See https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
82
82
|
def user_preferred_languages
|
83
|
-
languages = env['HTTP_ACCEPT_LANGUAGE'
|
83
|
+
languages = env['HTTP_ACCEPT_LANGUAGE']
|
84
84
|
languages.to_s.downcase.gsub(/\s+/, '').split(',').map do |language|
|
85
85
|
locale, quality = language.split(';q=', 2)
|
86
86
|
locale = nil if locale == '*' # Ignore wildcards
|
data/lib/sidekiq/web/router.rb
CHANGED
@@ -3,16 +3,16 @@ require 'rack'
|
|
3
3
|
|
4
4
|
module Sidekiq
|
5
5
|
module WebRouter
|
6
|
-
GET = 'GET'
|
7
|
-
DELETE = 'DELETE'
|
8
|
-
POST = 'POST'
|
9
|
-
PUT = 'PUT'
|
10
|
-
PATCH = 'PATCH'
|
11
|
-
HEAD = 'HEAD'
|
6
|
+
GET = 'GET'
|
7
|
+
DELETE = 'DELETE'
|
8
|
+
POST = 'POST'
|
9
|
+
PUT = 'PUT'
|
10
|
+
PATCH = 'PATCH'
|
11
|
+
HEAD = 'HEAD'
|
12
12
|
|
13
|
-
ROUTE_PARAMS = 'rack.route_params'
|
14
|
-
REQUEST_METHOD = 'REQUEST_METHOD'
|
15
|
-
PATH_INFO = 'PATH_INFO'
|
13
|
+
ROUTE_PARAMS = 'rack.route_params'
|
14
|
+
REQUEST_METHOD = 'REQUEST_METHOD'
|
15
|
+
PATH_INFO = 'PATH_INFO'
|
16
16
|
|
17
17
|
def get(path, &block)
|
18
18
|
route(GET, path, &block)
|
@@ -64,7 +64,7 @@ module Sidekiq
|
|
64
64
|
class WebRoute
|
65
65
|
attr_accessor :request_method, :pattern, :block, :name
|
66
66
|
|
67
|
-
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^\.:$\/]+)
|
67
|
+
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^\.:$\/]+)/
|
68
68
|
|
69
69
|
def initialize(request_method, pattern, block)
|
70
70
|
@request_method = request_method
|
data/lib/sidekiq/worker.rb
CHANGED
@@ -47,7 +47,7 @@ module Sidekiq
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def perform_async(*args)
|
50
|
-
@klass.client_push(@opts.merge('args'
|
50
|
+
@klass.client_push(@opts.merge('args' => args, 'class' => @klass))
|
51
51
|
end
|
52
52
|
|
53
53
|
# +interval+ must be a timestamp, numeric or something that acts
|
@@ -57,9 +57,9 @@ module Sidekiq
|
|
57
57
|
now = Time.now.to_f
|
58
58
|
ts = (int < 1_000_000_000 ? now + int : int)
|
59
59
|
|
60
|
-
payload = @opts.merge('class'
|
60
|
+
payload = @opts.merge('class' => @klass, 'args' => args, 'at' => ts)
|
61
61
|
# Optimization to enqueue something now that is scheduled to go out now or in the past
|
62
|
-
payload.delete('at'
|
62
|
+
payload.delete('at') if ts <= now
|
63
63
|
@klass.client_push(payload)
|
64
64
|
end
|
65
65
|
alias_method :perform_at, :perform_in
|
@@ -84,7 +84,7 @@ module Sidekiq
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def perform_async(*args)
|
87
|
-
client_push('class'
|
87
|
+
client_push('class' => self, 'args' => args)
|
88
88
|
end
|
89
89
|
|
90
90
|
# +interval+ must be a timestamp, numeric or something that acts
|
@@ -94,10 +94,10 @@ module Sidekiq
|
|
94
94
|
now = Time.now.to_f
|
95
95
|
ts = (int < 1_000_000_000 ? now + int : int)
|
96
96
|
|
97
|
-
item = { 'class'
|
97
|
+
item = { 'class' => self, 'args' => args, 'at' => ts }
|
98
98
|
|
99
99
|
# Optimization to enqueue something now that is scheduled to go out now or in the past
|
100
|
-
item.delete('at'
|
100
|
+
item.delete('at') if ts <= now
|
101
101
|
|
102
102
|
client_push(item)
|
103
103
|
end
|
@@ -134,7 +134,7 @@ module Sidekiq
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def client_push(item) # :nodoc:
|
137
|
-
pool = Thread.current[:sidekiq_via_pool] || get_sidekiq_options['pool'
|
137
|
+
pool = Thread.current[:sidekiq_via_pool] || get_sidekiq_options['pool'] || Sidekiq.redis_pool
|
138
138
|
# stringify
|
139
139
|
item.keys.each do |key|
|
140
140
|
item[key.to_s] = item.delete(key)
|
data/web/views/_footer.erb
CHANGED
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: 5.1.
|
4
|
+
version: 5.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: 2018-
|
11
|
+
date: 2018-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -201,7 +201,6 @@ files:
|
|
201
201
|
- lib/sidekiq/middleware/chain.rb
|
202
202
|
- lib/sidekiq/middleware/i18n.rb
|
203
203
|
- lib/sidekiq/middleware/server/active_record.rb
|
204
|
-
- lib/sidekiq/middleware/server/active_record_cache.rb
|
205
204
|
- lib/sidekiq/paginator.rb
|
206
205
|
- lib/sidekiq/processor.rb
|
207
206
|
- lib/sidekiq/rails.rb
|