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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fff631710094e52bd8a57c3ddd0367fa2466425
4
- data.tar.gz: 1310f9de542f0c123d39d45b1a8c7e1c09f36d58
3
+ metadata.gz: 7fbe302468cb06bdf841f96cbf31fe9d30ddfc1e
4
+ data.tar.gz: ffb44c96f5d912c067b0d09e00c517742a34dbe3
5
5
  SHA512:
6
- metadata.gz: c66ac1497ae96aa4c83b89966bfd79babd6ef7629e2916c3d0f441ca7e8f0a34c3d19cd86f37b1660965beded437f1059853a28547b0b5371456c5fe159648a2
7
- data.tar.gz: 26bbe0b74f3d76e821f05e7811c1ae7dd9021cffad3fe9f9644e85b8ecc8f9b2ece98632cd4de17f27a3ffa2f3913ce8e60e6149c8dd5758fd409b4e93725347
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
 
@@ -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 http://sidekiq.org/pro/ for
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.
@@ -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
 
@@ -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'.freeze
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
- }.freeze
50
+ }
52
51
 
53
52
  def self.❨╯°□°❩╯︵┻━┻
54
53
  puts "Calm down, yo."
@@ -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'.freeze)
55
- conn.get('stat:failed'.freeze)
56
- conn.zcard('schedule'.freeze)
57
- conn.zcard('retry'.freeze)
58
- conn.zcard('dead'.freeze)
59
- conn.scard('processes'.freeze)
60
- conn.lrange('queue:default'.freeze, -1, -1)
61
- conn.smembers('processes'.freeze)
62
- conn.smembers('queues'.freeze)
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'.freeze) }
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'.freeze] || now
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'.freeze)
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".freeze)
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'.freeze) }.sort.map { |q| Sidekiq::Queue.new(q) }
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".freeze, name)
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'.freeze]
351
+ if self['encrypt']
353
352
  # no point in showing 150+ bytes of random garbage
354
- args[-1] = '[encrypted data]'.freeze
353
+ args[-1] = '[encrypted data]'
355
354
  end
356
355
  args
357
356
  end
@@ -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'.freeze },
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.puts(sig)
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
@@ -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'.freeze], normed)
71
+ payload = process_single(item['class'], normed)
72
72
 
73
73
  if payload
74
74
  raw_push([payload])
75
- payload['jid'.freeze]
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'.freeze].first
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'.freeze].map do |args|
98
- copy = normed.merge('args'.freeze => args, 'jid'.freeze => SecureRandom.hex(12), 'enqueued_at'.freeze => Time.now.to_f)
99
- result = process_single(items['class'.freeze], copy)
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'.freeze] }
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'.freeze => klass, 'args'.freeze => args)
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'.freeze => queue, 'class'.freeze => klass, 'args'.freeze => args)
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'.freeze => klass, 'args'.freeze => args, 'at'.freeze => ts, 'queue'.freeze => queue }
166
- item.delete('at'.freeze) if ts <= now
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'.freeze]
192
- conn.zadd('schedule'.freeze, payloads.map do |hash|
193
- at = hash.delete('at'.freeze).to_s
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'.freeze]
197
+ q = payloads.first['queue']
198
198
  now = Time.now.to_f
199
199
  to_push = payloads.map do |entry|
200
- entry['enqueued_at'.freeze] = now
200
+ entry['enqueued_at'] = now
201
201
  Sidekiq.dump_json(entry)
202
202
  end
203
- conn.sadd('queues'.freeze, q)
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'.freeze]
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'.freeze) && item.has_key?('args'.freeze)
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'.freeze].is_a?(Class) || item['class'.freeze].is_a?(String)
220
- raise(ArgumentError, "Job 'at' must be a Numeric timestamp") if item.has_key?('at'.freeze) && !item['at'].is_a?(Numeric)
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'.freeze])
223
+ normalized_hash(item['class'])
224
224
  .each{ |key, value| item[key] = value if item[key].nil? }
225
225
 
226
- item['class'.freeze] = item['class'.freeze].to_s
227
- item['queue'.freeze] = item['queue'.freeze].to_s
228
- item['jid'.freeze] ||= SecureRandom.hex(12)
229
- item['created_at'.freeze] ||= Time.now.to_f
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'.freeze)
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Sidekiq
2
3
  module Extensions
3
4
 
@@ -13,7 +13,7 @@ module Sidekiq
13
13
  end
14
14
 
15
15
  def queue_name
16
- queue.sub(/.*queue:/, ''.freeze)
16
+ queue.sub(/.*queue:/, '')
17
17
  end
18
18
 
19
19
  def requeue
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  module Sidekiq
2
3
  class JobLogger
3
4
 
4
5
  def call(item, queue)
5
6
  start = Time.now
6
- logger.info("start".freeze)
7
+ logger.info("start")
7
8
  yield
8
9
  logger.info("done: #{elapsed(start)} sec")
9
10
  rescue Exception
@@ -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 && retry_in(worker, count, exception) || seconds_to_delay(count)
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).to_i
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
@@ -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".freeze
80
- nowdate = Time.now.utc.strftime("%Y-%m-%d".freeze)
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".freeze, procd)
82
+ conn.incrby("stat:processed", procd)
84
83
  conn.incrby("stat:processed:#{nowdate}", procd)
85
- conn.incrby("stat:failed".freeze, fails)
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|
@@ -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'.freeze] || job_hash["class".freeze]
37
- bid = job_hash['bid'.freeze]
38
- "#{klass} JID-#{job_hash['jid'.freeze]}#{" BID-#{bid}" if bid}"
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)
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
  require 'sidekiq/util'
4
3
  require 'sidekiq/processor'
@@ -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
@@ -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'.freeze])
135
+ klass = constantize(job_hash['class'])
136
136
  worker = klass.new
137
- worker.jid = job_hash['jid'.freeze]
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'.freeze]))
169
+ execute_job(worker, cloned(job_hash['args']))
170
170
  end
171
171
  end
172
172
  rescue Sidekiq::Shutdown
@@ -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
- if ::Rails::VERSION::MAJOR < 5
15
- require 'sidekiq/middleware/server/active_record'
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] || (Sidekiq.server? ? (Sidekiq.options[:concurrency] + 5) : 5)
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'.freeze
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
@@ -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'.freeze, now, :limit => [0, 1]).first do
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
@@ -21,7 +21,7 @@ module Sidekiq
21
21
 
22
22
  def safe_thread(name, &block)
23
23
  Thread.new do
24
- Thread.current['sidekiq_label'.freeze] = name
24
+ Thread.current['sidekiq_label'] = name
25
25
  watchdog(name, &block)
26
26
  end
27
27
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Sidekiq
3
- VERSION = "5.1.1"
3
+ VERSION = "5.1.2"
4
4
  end
@@ -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".freeze
23
- LOCALES = ["#{ROOT}/locales".freeze]
24
- LAYOUT = "#{VIEWS}/layout.erb".freeze
25
- ASSETS = "#{ROOT}/assets".freeze
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" => '',
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Sidekiq
4
4
  class WebAction
5
- RACK_SESSION = 'rack.session'.freeze
5
+ RACK_SESSION = 'rack.session'
6
6
 
7
7
  attr_accessor :env, :block, :type
8
8
 
@@ -4,8 +4,8 @@ module Sidekiq
4
4
  class WebApplication
5
5
  extend WebRouter
6
6
 
7
- CONTENT_LENGTH = "Content-Length".freeze
8
- CONTENT_TYPE = "Content-Type".freeze
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)
@@ -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'.freeze]
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
@@ -3,16 +3,16 @@ require 'rack'
3
3
 
4
4
  module Sidekiq
5
5
  module WebRouter
6
- GET = 'GET'.freeze
7
- DELETE = 'DELETE'.freeze
8
- POST = 'POST'.freeze
9
- PUT = 'PUT'.freeze
10
- PATCH = 'PATCH'.freeze
11
- HEAD = 'HEAD'.freeze
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'.freeze
14
- REQUEST_METHOD = 'REQUEST_METHOD'.freeze
15
- PATH_INFO = 'PATH_INFO'.freeze
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 = /\/([^\/]*):([^\.:$\/]+)/.freeze
67
+ NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^\.:$\/]+)/
68
68
 
69
69
  def initialize(request_method, pattern, block)
70
70
  @request_method = request_method
@@ -47,7 +47,7 @@ module Sidekiq
47
47
  end
48
48
 
49
49
  def perform_async(*args)
50
- @klass.client_push(@opts.merge('args'.freeze => args, 'class'.freeze => @klass))
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'.freeze => @klass, 'args'.freeze => args, 'at'.freeze => ts)
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'.freeze) if ts <= now
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'.freeze => self, 'args'.freeze => args)
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'.freeze => self, 'args'.freeze => args, 'at'.freeze => ts }
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'.freeze) if ts <= now
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'.freeze] || Sidekiq.redis_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)
@@ -11,6 +11,9 @@
11
11
  <li>
12
12
  <p class="navbar-text server-utc-time"><%= server_utc_time %></p>
13
13
  </li>
14
+ <li>
15
+ <p class="navbar-text"><a style="color: gray;" href="https://github.com/mperham/sidekiq/wiki">docs</a></p>
16
+ </li>
14
17
  </ul>
15
18
  </div>
16
19
  </div>
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.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-02-08 00:00:00.000000000 Z
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
@@ -1,11 +0,0 @@
1
- module Sidekiq
2
- module Middleware
3
- module Server
4
- class ActiveRecordCache
5
- def call(*args, &block)
6
- ::ActiveRecord::Base.cache(&block)
7
- end
8
- end
9
- end
10
- end
11
- end