sidekiq 2.17.4 → 2.17.5

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: f0aa7427773926eb8405b61c3f23ca7f76d2c30a
4
- data.tar.gz: 4718ae00e33055fa689059cbfa1f9ef376849109
3
+ metadata.gz: f45fd360f6855464c593e4fb45908eb33dcb0efe
4
+ data.tar.gz: b635fac989f62f29bd4f7f740343851560bb6829
5
5
  SHA512:
6
- metadata.gz: fc0f9e9373b76a5c9944e00de83edada7a886181d49ce11f70582cb6a8f2c35514d350dd6987d26abbe92ae91639661d414be1ba76e6f509577fb461c2396319
7
- data.tar.gz: d6efd568f255aac569dc64f9de9fe73984a76aaf72413551f977ba1f2037eee4dfc7350209d06bf66fc19a3ab5e8b250985ff27eff3cec8d8ccfcbc494c14d10
6
+ metadata.gz: b56a2d5b412234622fc5e531c5402d5b9c8251373250eaadaa8c37a3918145d1afd740ee4b9311ce9bcb0fa08fd172a397a5ba3ab97c3271541a11a0524c2898
7
+ data.tar.gz: d1e0f55a98d11c4d15a4e3bec401ac571e482b1973869c66f7f40a433895aabb8a920085d5341c9ecc0f873d28f76925ea72dffa2884286ad26b61865e80e5a4
@@ -9,5 +9,4 @@ rvm:
9
9
  - 2.1.0
10
10
  matrix:
11
11
  allow_failures:
12
- - rvm: jruby-19mode
13
12
  - rvm: rbx
data/Changes.md CHANGED
@@ -1,3 +1,12 @@
1
+ 2.17.5
2
+ -----------
3
+
4
+ - Automatically use the config file found at `config/sidekiq.yml`, if not passed `-C`. [#1481]
5
+ - Store 'retried\_at' and 'failed\_at' timestamps as Floats, not Strings. [#1473]
6
+ - A `USR2` signal will now reopen _all_ logs, using IO#reopen. Thus, instead of creating a new Logger object,
7
+ Sidekiq will now just update the existing Logger's file descriptor [#1163].
8
+ - Remove pidfile when shutting down if started with `-P` [#1470]
9
+
1
10
  2.17.4
2
11
  -----------
3
12
 
data/Gemfile CHANGED
@@ -7,3 +7,12 @@ platforms :rbx do
7
7
  gem 'minitest' # if using minitest
8
8
  gem 'rubinius-developer_tools' # if using any of coverage, debugger, profiler
9
9
  end
10
+
11
+ platforms :ruby do
12
+ gem 'sqlite3'
13
+ end
14
+
15
+ platforms :jruby do
16
+ gem 'jruby-openssl'
17
+ gem 'activerecord-jdbcsqlite3-adapter'
18
+ end
@@ -3,6 +3,11 @@ Sidekiq Pro Changelog
3
3
 
4
4
  Please see [http://sidekiq.org/pro](http://sidekiq.org/pro) for more details and how to buy.
5
5
 
6
+ HEAD
7
+ -----------
8
+
9
+ - Reverse sorting of Batches in Web UI [#1098]
10
+
6
11
  1.4.2
7
12
  -----------
8
13
 
data/config.ru CHANGED
@@ -12,7 +12,7 @@ end
12
12
  #Sidekiq.redis { |conn| conn.zadd('retry', Time.now.utc.to_f + 3000, MultiJson.encode({
13
13
  #'class' => 'HardWorker', 'args' => ['foo', 0.1, Time.now.to_f],
14
14
  #'queue' => 'default', 'error_message' => 'No such method', 'error_class' => 'NoMethodError',
15
- #'failed_at' => Time.now.utc, 'retry_count' => 0 })) }
15
+ #'failed_at' => Time.now.to_i, 'retry_count' => 0 })) }
16
16
 
17
17
  require 'sidekiq/web'
18
18
  run Sidekiq::Web
@@ -1,7 +1,38 @@
1
1
  module Sidekiq
2
2
  module Actor
3
+
4
+ module ClassMethods
5
+ def trap_exit(*args)
6
+ end
7
+ def new_link(*args)
8
+ new(*args)
9
+ end
10
+ end
11
+
12
+ module InstanceMethods
13
+ def current_actor
14
+ self
15
+ end
16
+ def after(interval)
17
+ end
18
+ def alive?
19
+ !@dead
20
+ end
21
+ def terminate
22
+ @dead = true
23
+ end
24
+ def defer
25
+ yield
26
+ end
27
+ end
28
+
3
29
  def self.included(klass)
4
- klass.send(:include, Celluloid)
30
+ if $TESTING
31
+ klass.__send__(:include, InstanceMethods)
32
+ klass.__send__(:extend, ClassMethods)
33
+ else
34
+ klass.__send__(:include, Celluloid)
35
+ end
5
36
  end
6
37
  end
7
38
  end
@@ -203,7 +203,7 @@ module Sidekiq
203
203
  end
204
204
 
205
205
  def [](name)
206
- @item.send(:[], name)
206
+ @item.__send__(:[], name)
207
207
  end
208
208
  end
209
209
 
@@ -257,18 +257,20 @@ module Sidekiq
257
257
  class SortedSet
258
258
  include Enumerable
259
259
 
260
+ attr_reader :name
261
+
260
262
  def initialize(name)
261
- @zset = name
263
+ @name = name
262
264
  @_size = size
263
265
  end
264
266
 
265
267
  def size
266
- Sidekiq.redis {|c| c.zcard(@zset) }
268
+ Sidekiq.redis {|c| c.zcard(name) }
267
269
  end
268
270
 
269
271
  def schedule(timestamp, message)
270
272
  Sidekiq.redis do |conn|
271
- conn.zadd(@zset, timestamp.to_f.to_s, Sidekiq.dump_json(message))
273
+ conn.zadd(name, timestamp.to_f.to_s, Sidekiq.dump_json(message))
272
274
  end
273
275
  end
274
276
 
@@ -282,7 +284,7 @@ module Sidekiq
282
284
  range_start = page * page_size + offset_size
283
285
  range_end = page * page_size + offset_size + (page_size - 1)
284
286
  elements = Sidekiq.redis do |conn|
285
- conn.zrange @zset, range_start, range_end, :with_scores => true
287
+ conn.zrange name, range_start, range_end, :with_scores => true
286
288
  end
287
289
  break if elements.empty?
288
290
  page -= 1
@@ -295,7 +297,7 @@ module Sidekiq
295
297
 
296
298
  def fetch(score, jid = nil)
297
299
  elements = Sidekiq.redis do |conn|
298
- conn.zrangebyscore(@zset, score, score)
300
+ conn.zrangebyscore(name, score, score)
299
301
  end
300
302
 
301
303
  elements.inject([]) do |result, element|
@@ -316,7 +318,7 @@ module Sidekiq
316
318
  def delete(score, jid = nil)
317
319
  if jid
318
320
  elements = Sidekiq.redis do |conn|
319
- conn.zrangebyscore(@zset, score, score)
321
+ conn.zrangebyscore(name, score, score)
320
322
  end
321
323
 
322
324
  elements_with_jid = elements.map do |element|
@@ -325,8 +327,8 @@ module Sidekiq
325
327
  if message["jid"] == jid
326
328
  _, @_size = Sidekiq.redis do |conn|
327
329
  conn.multi do
328
- conn.zrem(@zset, element)
329
- conn.zcard @zset
330
+ conn.zrem(name, element)
331
+ conn.zcard name
330
332
  end
331
333
  end
332
334
  end
@@ -335,8 +337,8 @@ module Sidekiq
335
337
  else
336
338
  count, @_size = Sidekiq.redis do |conn|
337
339
  conn.multi do
338
- conn.zremrangebyscore(@zset, score, score)
339
- conn.zcard @zset
340
+ conn.zremrangebyscore(name, score, score)
341
+ conn.zcard name
340
342
  end
341
343
  end
342
344
  count != 0
@@ -345,7 +347,7 @@ module Sidekiq
345
347
 
346
348
  def clear
347
349
  Sidekiq.redis do |conn|
348
- conn.del(@zset)
350
+ conn.del(name)
349
351
  end
350
352
  end
351
353
  end
@@ -40,7 +40,7 @@ Capistrano::Configuration.instance.load do
40
40
  task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
41
41
  rails_env = fetch(:rails_env, "production")
42
42
  for_each_process do |pid_file, idx|
43
- run "cd #{current_path} ; nohup #{fetch(:sidekiq_cmd)} -e #{rails_env} -C #{current_path}/config/sidekiq.yml -i #{idx} -P #{pid_file} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
43
+ run "cd #{current_path} ; nohup #{fetch(:sidekiq_cmd)} -e #{rails_env} -i #{idx} -P #{pid_file} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
44
44
  end
45
45
  end
46
46
 
@@ -108,7 +108,7 @@ module Sidekiq
108
108
  when 'USR2'
109
109
  if Sidekiq.options[:logfile]
110
110
  Sidekiq.logger.info "Received USR2, reopening log file"
111
- initialize_logger
111
+ Sidekiq::Logging.reopen_logs
112
112
  end
113
113
  when 'TTIN'
114
114
  Thread.list.each do |thread|
@@ -179,7 +179,7 @@ module Sidekiq
179
179
 
180
180
  cfile = opts[:config_file]
181
181
  opts = parse_config(cfile).merge(opts) if cfile
182
-
182
+
183
183
  opts[:strict] = true if opts[:strict].nil?
184
184
 
185
185
  options.merge!(opts)
@@ -299,6 +299,7 @@ module Sidekiq
299
299
  die 1
300
300
  end
301
301
  @parser.parse!(argv)
302
+ opts[:config_file] ||= 'config/sidekiq.yml' if File.exist?('config/sidekiq.yml')
302
303
  opts
303
304
  end
304
305
 
@@ -313,6 +314,9 @@ module Sidekiq
313
314
  File.open(path, 'w') do |f|
314
315
  f.puts Process.pid
315
316
  end
317
+ at_exit do
318
+ FileUtils.rm_f path
319
+ end
316
320
  end
317
321
  end
318
322
 
@@ -14,7 +14,7 @@ module Sidekiq
14
14
 
15
15
  def perform(yml)
16
16
  (target, method_name, args) = YAML.load(yml)
17
- msg = target.send(method_name, *args)
17
+ msg = target.__send__(method_name, *args)
18
18
  # The email method can return nil, which causes ActionMailer to return
19
19
  # an undeliverable empty message.
20
20
  msg.deliver if msg && (msg.to || msg.cc || msg.bcc) && msg.from
@@ -16,7 +16,7 @@ module Sidekiq
16
16
 
17
17
  def perform(yml)
18
18
  (target, method_name, args) = YAML.load(yml)
19
- target.send(method_name, *args)
19
+ target.__send__(method_name, *args)
20
20
  end
21
21
  end
22
22
 
@@ -14,7 +14,7 @@ module Sidekiq
14
14
 
15
15
  def perform(yml)
16
16
  (target, method_name, args) = YAML.load(yml)
17
- target.send(method_name, *args)
17
+ target.__send__(method_name, *args)
18
18
  end
19
19
  end
20
20
 
@@ -36,4 +36,4 @@ module Sidekiq
36
36
  end
37
37
  end
38
38
 
39
- Module.send(:include, Sidekiq::Extensions::Klass)
39
+ Module.__send__(:include, Sidekiq::Extensions::Klass)
@@ -12,6 +12,8 @@ module Sidekiq
12
12
 
13
13
  TIMEOUT = 1
14
14
 
15
+ attr_reader :down
16
+
15
17
  def initialize(mgr, options)
16
18
  @down = nil
17
19
  @mgr = mgr
@@ -47,6 +49,12 @@ module Sidekiq
47
49
  end
48
50
  end
49
51
 
52
+ private
53
+
54
+ def pause
55
+ sleep(TIMEOUT)
56
+ end
57
+
50
58
  def handle_fetch_exception(ex)
51
59
  if !@down
52
60
  logger.error("Error fetching message: #{ex}")
@@ -55,7 +63,7 @@ module Sidekiq
55
63
  end
56
64
  end
57
65
  @down ||= Time.now
58
- sleep(TIMEOUT)
66
+ pause
59
67
  after(0) { fetch }
60
68
  rescue Task::TerminatedError
61
69
  # If redis is down when we try to shut down, all the fetch backlog
@@ -69,6 +77,10 @@ module Sidekiq
69
77
  @done = true
70
78
  end
71
79
 
80
+ def self.reset # testing only
81
+ @done = nil
82
+ end
83
+
72
84
  def self.done?
73
85
  @done
74
86
  end
@@ -42,6 +42,51 @@ module Sidekiq
42
42
  @logger = (log ? log : Logger.new('/dev/null'))
43
43
  end
44
44
 
45
+ # This reopens ALL logfiles in the process that have been rotated
46
+ # using logrotate(8) (without copytruncate) or similar tools.
47
+ # A +File+ object is considered for reopening if it is:
48
+ # 1) opened with the O_APPEND and O_WRONLY flags
49
+ # 2) the current open file handle does not match its original open path
50
+ # 3) unbuffered (as far as userspace buffering goes, not O_SYNC)
51
+ # Returns the number of files reopened
52
+ def self.reopen_logs
53
+ to_reopen = []
54
+ append_flags = File::WRONLY | File::APPEND
55
+
56
+ ObjectSpace.each_object(File) do |fp|
57
+ begin
58
+ if !fp.closed? && fp.stat.file? && fp.sync && (fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags
59
+ to_reopen << fp
60
+ end
61
+ rescue IOError, Errno::EBADF
62
+ end
63
+ end
64
+
65
+ nr = 0
66
+ to_reopen.each do |fp|
67
+ orig_st = begin
68
+ fp.stat
69
+ rescue IOError, Errno::EBADF
70
+ next
71
+ end
72
+
73
+ begin
74
+ b = File.stat(fp.path)
75
+ next if orig_st.ino == b.ino && orig_st.dev == b.dev
76
+ rescue Errno::ENOENT
77
+ end
78
+
79
+ begin
80
+ File.open(fp.path, 'a') { |tmpfp| fp.reopen(tmpfp) }
81
+ fp.sync = true
82
+ nr += 1
83
+ rescue IOError, Errno::EBADF
84
+ # not much we can do...
85
+ end
86
+ end
87
+ nr
88
+ end
89
+
45
90
  def logger
46
91
  Sidekiq::Logging.logger
47
92
  end
@@ -75,10 +75,10 @@ module Sidekiq
75
75
  msg['error_message'] = e.message
76
76
  msg['error_class'] = e.class.name
77
77
  count = if msg['retry_count']
78
- msg['retried_at'] = Time.now.utc
78
+ msg['retried_at'] = Time.now.to_f
79
79
  msg['retry_count'] += 1
80
80
  else
81
- msg['failed_at'] = Time.now.utc
81
+ msg['failed_at'] = Time.now.to_f
82
82
  msg['retry_count'] = 0
83
83
  end
84
84
 
@@ -13,7 +13,7 @@ module Sidekiq
13
13
 
14
14
  case type
15
15
  when 'zset'
16
- rev = opts.try(:[], :reverse)
16
+ rev = opts && opts[:reverse]
17
17
  total_size, items = conn.multi do
18
18
  conn.zcard(key)
19
19
  if rev
@@ -1,7 +1,7 @@
1
1
  module Sidekiq
2
2
  def self.hook_rails!
3
3
  if defined?(::ActiveRecord)
4
- ::ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)
4
+ ::ActiveRecord::Base.__send__(:include, Sidekiq::Extensions::ActiveRecord)
5
5
  end
6
6
 
7
7
  if defined?(::ActionMailer)
@@ -15,7 +15,7 @@ namespace :load do
15
15
  set :sidekiq_pid, ->{ "tmp/sidekiq.pid" }
16
16
 
17
17
  # "-d -i INT -P PATH" are added automatically.
18
- set :sidekiq_options, ->{ "-e #{fetch(:rails_env, 'production')} -C #{current_path}/config/sidekiq.yml -L #{current_path}/log/sidekiq.log" }
18
+ set :sidekiq_options, ->{ "-e #{fetch(:rails_env, 'production')} -L #{current_path}/log/sidekiq.log" }
19
19
 
20
20
  set :sidekiq_timeout, ->{ 10 }
21
21
  set :sidekiq_role, ->{ :app }
@@ -91,10 +91,19 @@ namespace :sidekiq do
91
91
  rails_env = fetch(:rails_env, "production")
92
92
  within current_path do
93
93
  for_each_process do |pid_file, idx|
94
- if fetch(:sidekiq_cmd)
95
- execute fetch(:sidekiq_cmd), "-d -i #{idx} -P #{pid_full_path(pid_file)} #{fetch(:sidekiq_options)}"
94
+ if !defined? JRUBY_VERSION
95
+ if fetch(:sidekiq_cmd)
96
+ execute fetch(:sidekiq_cmd), "-d -i #{idx} -P #{pid_full_path(pid_file)} #{fetch(:sidekiq_options)}"
97
+ else
98
+ execute :bundle, :exec, :sidekiq, "-d -i #{idx} -P #{pid_full_path(pid_file)} #{fetch(:sidekiq_options)}"
99
+ end
96
100
  else
97
- execute :bundle, :exec, :sidekiq, "-d -i #{idx} -P #{pid_full_path(pid_file)} #{fetch(:sidekiq_options)}"
101
+ execute "echo 'Since JRuby doesn't support Process.daemon, Sidekiq will be running without the -d flag."
102
+ if fetch(:sidekiq_cmd)
103
+ execute fetch(:sidekiq_cmd), "-i #{idx} -P #{pid_full_path(pid_file)} #{fetch(:sidekiq_options)} >/dev/null 2>&1 &"
104
+ else
105
+ execute :bundle, :exec, :sidekiq, "-i #{idx} -P #{pid_full_path(pid_file)} #{fetch(:sidekiq_options)} >/dev/null 2>&1 &"
106
+ end
98
107
  end
99
108
  end
100
109
  end
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "2.17.4"
2
+ VERSION = "2.17.5"
3
3
  end
@@ -22,7 +22,6 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'sinatra'
23
23
  gem.add_development_dependency 'minitest', '~> 4.2'
24
24
  gem.add_development_dependency 'rake'
25
- gem.add_development_dependency 'actionmailer', '>= 4.0.0'
26
- gem.add_development_dependency 'activerecord', '>= 4.0.0'
25
+ gem.add_development_dependency 'rails', '>= 4.0.0'
27
26
  gem.add_development_dependency 'coveralls'
28
27
  end
@@ -2,6 +2,7 @@ $TESTING = true
2
2
  require 'coveralls'
3
3
  Coveralls.wear! do
4
4
  add_filter "/test/"
5
+ add_filter "/myapp/"
5
6
  end
6
7
 
7
8
  ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
@@ -9,6 +10,7 @@ if ENV.has_key?("SIMPLECOV")
9
10
  require 'simplecov'
10
11
  SimpleCov.start do
11
12
  add_filter "/test/"
13
+ add_filter "/myapp/"
12
14
  end
13
15
  end
14
16
 
@@ -381,7 +381,7 @@ class TestApi < Sidekiq::Test
381
381
  end
382
382
 
383
383
  def add_retry(jid = 'bob', at = Time.now.to_f)
384
- payload = Sidekiq.dump_json('class' => 'ApiWorker', 'args' => [1, 'mike'], 'queue' => 'default', 'jid' => jid, 'retry_count' => 2, 'failed_at' => Time.now.utc)
384
+ payload = Sidekiq.dump_json('class' => 'ApiWorker', 'args' => [1, 'mike'], 'queue' => 'default', 'jid' => jid, 'retry_count' => 2, 'failed_at' => Time.now.to_f)
385
385
  Sidekiq.redis do |conn|
386
386
  conn.zadd('retry', at.to_s, payload)
387
387
  end
@@ -30,6 +30,12 @@ class TestCli < Sidekiq::Test
30
30
  assert @cli.valid?
31
31
  end
32
32
 
33
+ it 'boots rails' do
34
+ refute defined?(::Rails)
35
+ @cli.parse(['sidekiq', '-r', './myapp'])
36
+ assert defined?(::Rails)
37
+ end
38
+
33
39
  it 'changes concurrency' do
34
40
  @cli.parse(['sidekiq', '-c', '60', '-r', './test/fake_env.rb'])
35
41
  assert_equal 60, Sidekiq.options[:concurrency]
@@ -288,8 +294,8 @@ class TestCli < Sidekiq::Test
288
294
  describe 'when weight is present' do
289
295
  it 'concatenates queues by factor of weight and sets strict to false' do
290
296
  opts = { strict: true }
291
- @cli.send :parse_queues, opts, [['often', 7], ['repeatedly', 3]]
292
- @cli.send :parse_queues, opts, [['once']]
297
+ @cli.__send__ :parse_queues, opts, [['often', 7], ['repeatedly', 3]]
298
+ @cli.__send__ :parse_queues, opts, [['once']]
293
299
  assert_equal (%w[often] * 7 + %w[repeatedly] * 3 + %w[once]), opts[:queues]
294
300
  assert !opts[:strict]
295
301
  end
@@ -298,8 +304,8 @@ class TestCli < Sidekiq::Test
298
304
  describe 'when weight is not present' do
299
305
  it 'returns queues and sets strict' do
300
306
  opts = { strict: true }
301
- @cli.send :parse_queues, opts, [['once'], ['one_time']]
302
- @cli.send :parse_queues, opts, [['einmal']]
307
+ @cli.__send__ :parse_queues, opts, [['once'], ['one_time']]
308
+ @cli.__send__ :parse_queues, opts, [['einmal']]
303
309
  assert_equal %w[once one_time einmal], opts[:queues]
304
310
  assert opts[:strict]
305
311
  end
@@ -310,7 +316,7 @@ class TestCli < Sidekiq::Test
310
316
  describe 'when weight is present' do
311
317
  it 'concatenates queue to opts[:queues] weight number of times and sets strict to false' do
312
318
  opts = { strict: true }
313
- @cli.send :parse_queue, opts, 'often', 7
319
+ @cli.__send__ :parse_queue, opts, 'often', 7
314
320
  assert_equal %w[often] * 7, opts[:queues]
315
321
  assert !opts[:strict]
316
322
  end
@@ -319,7 +325,7 @@ class TestCli < Sidekiq::Test
319
325
  describe 'when weight is not present' do
320
326
  it 'concatenates queue to opts[:queues] once and leaves strict true' do
321
327
  opts = { strict: true }
322
- @cli.send :parse_queue, opts, 'once', nil
328
+ @cli.__send__ :parse_queue, opts, 'once', nil
323
329
  assert_equal %w[once], opts[:queues]
324
330
  assert opts[:strict]
325
331
  end
@@ -226,11 +226,11 @@ class TestClient < Sidekiq::Test
226
226
 
227
227
  describe 'item normalization' do
228
228
  it 'defaults retry to true' do
229
- assert_equal true, Sidekiq::Client.new.send(:normalize_item, 'class' => QueuedWorker, 'args' => [])['retry']
229
+ assert_equal true, Sidekiq::Client.new.__send__(:normalize_item, 'class' => QueuedWorker, 'args' => [])['retry']
230
230
  end
231
231
 
232
232
  it "does not normalize numeric retry's" do
233
- assert_equal 2, Sidekiq::Client.new.send(:normalize_item, 'class' => CWorker, 'args' => [])['retry']
233
+ assert_equal 2, Sidekiq::Client.new.__send__(:normalize_item, 'class' => CWorker, 'args' => [])['retry']
234
234
  end
235
235
  end
236
236
  end
@@ -59,7 +59,7 @@ class TestExceptionHandler < Sidekiq::Test
59
59
  end
60
60
 
61
61
  after do
62
- Object.send(:remove_const, "Airbrake") # HACK should probably inject Airbrake etc into this class in the future
62
+ Object.__send__(:remove_const, "Airbrake") # HACK should probably inject Airbrake etc into this class in the future
63
63
  end
64
64
 
65
65
  it "notifies Airbrake" do
@@ -75,7 +75,7 @@ class TestExceptionHandler < Sidekiq::Test
75
75
  end
76
76
 
77
77
  after do
78
- Object.send(:remove_const, "Honeybadger") # HACK should probably inject Honeybadger etc into this class in the future
78
+ Object.__send__(:remove_const, "Honeybadger") # HACK should probably inject Honeybadger etc into this class in the future
79
79
  end
80
80
 
81
81
  it "notifies Honeybadger" do
@@ -91,7 +91,7 @@ class TestExceptionHandler < Sidekiq::Test
91
91
  end
92
92
 
93
93
  after do
94
- Object.send(:remove_const, "ExceptionNotifier")
94
+ Object.__send__(:remove_const, "ExceptionNotifier")
95
95
  end
96
96
 
97
97
  it "notifies ExceptionNotifier" do
@@ -120,7 +120,7 @@ class TestExceptionHandler < Sidekiq::Test
120
120
  end
121
121
 
122
122
  after do
123
- Object.send(:remove_const, "Exceptional")
123
+ Object.__send__(:remove_const, "Exceptional")
124
124
  end
125
125
 
126
126
  it "notifies Exceptional" do
@@ -40,5 +40,61 @@ class TestFetcher < Sidekiq::Test
40
40
  assert_equal 2, q1.size
41
41
  assert_equal 1, q2.size
42
42
  end
43
+
44
+ describe 'fetching' do
45
+ before do
46
+ Sidekiq::Fetcher.reset
47
+ end
48
+
49
+ it 'instantiates' do
50
+ begin
51
+ Sidekiq.options[:fetch] = NullFetch
52
+ mgr = Minitest::Mock.new
53
+ fetch = Sidekiq::Fetcher.new(mgr, {})
54
+ fetch.fetch
55
+ Sidekiq::Fetcher.done!
56
+ ensure
57
+ Sidekiq.options[:fetch] = Sidekiq::BasicFetch
58
+ end
59
+ end
60
+
61
+ class NullFetch
62
+ def initialize(opts)
63
+ end
64
+ def retrieve_work
65
+ end
66
+ def self.bulk_requeue(*args)
67
+ end
68
+ end
69
+
70
+ it 'handles redis network errors' do
71
+ begin
72
+ Sidekiq.logger.level = Logger::FATAL
73
+ Sidekiq.options[:fetch] = ErrorFetch
74
+ mgr = Minitest::Mock.new
75
+ fetch = Sidekiq::Fetcher.new(mgr, {})
76
+ def fetch.pause
77
+ end
78
+ refute fetch.down
79
+ fetch.fetch
80
+ Sidekiq::Fetcher.done!
81
+ assert fetch.down
82
+ ensure
83
+ Sidekiq.options[:fetch] = Sidekiq::BasicFetch
84
+ Sidekiq.logger.level = Logger::ERROR
85
+ end
86
+ end
87
+
88
+ class ErrorFetch
89
+ def initialize(opts)
90
+ end
91
+ def retrieve_work
92
+ raise IOError, "ker-BOOM"
93
+ end
94
+ def self.bulk_requeue(*args)
95
+ end
96
+ end
97
+ end
98
+
43
99
  end
44
100
  end
@@ -77,7 +77,7 @@ class TestRedisConnection < Sidekiq::Test
77
77
  ENV[v] = nil
78
78
  end
79
79
  ENV[var] = uri
80
- assert_equal uri, Sidekiq::RedisConnection.send(:determine_redis_provider)
80
+ assert_equal uri, Sidekiq::RedisConnection.__send__(:determine_redis_provider)
81
81
  ENV[var] = nil
82
82
  end
83
83
 
@@ -129,7 +129,7 @@ class TestRetry < Sidekiq::Test
129
129
 
130
130
  it 'handles a recurring failed message' do
131
131
  @redis.expect :zadd, 1, ['retry', String, String]
132
- now = Time.now.utc
132
+ now = Time.now.to_f
133
133
  msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], 'retry' => true, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry_count"=>10}
134
134
  handler = Sidekiq::Middleware::Server::RetryJobs.new
135
135
  assert_raises RuntimeError do
@@ -147,7 +147,7 @@ class TestRetry < Sidekiq::Test
147
147
 
148
148
  it 'handles a recurring failed message before reaching user-specifed max' do
149
149
  @redis.expect :zadd, 1, ['retry', String, String]
150
- now = Time.now.utc
150
+ now = Time.now.to_f
151
151
  msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], 'retry' => 10, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry_count"=>8}
152
152
  handler = Sidekiq::Middleware::Server::RetryJobs.new
153
153
  assert_raises RuntimeError do
@@ -164,7 +164,7 @@ class TestRetry < Sidekiq::Test
164
164
  end
165
165
 
166
166
  it 'throws away old messages after too many retries (using the default)' do
167
- now = Time.now.utc
167
+ now = Time.now.to_f
168
168
  msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry"=>true, "retry_count"=>25}
169
169
  @redis.expect :zadd, 1, [ 'retry', String, String ]
170
170
  handler = Sidekiq::Middleware::Server::RetryJobs.new
@@ -178,7 +178,7 @@ class TestRetry < Sidekiq::Test
178
178
  end
179
179
 
180
180
  it 'throws away old messages after too many retries (using user-specified max)' do
181
- now = Time.now.utc
181
+ now = Time.now.to_f
182
182
  msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry"=>3, "retry_count"=>3}
183
183
  @redis.expect :zadd, 1, [ 'retry', String, String ]
184
184
  handler = Sidekiq::Middleware::Server::RetryJobs.new
@@ -194,7 +194,7 @@ class TestRetry < Sidekiq::Test
194
194
  describe "retry exhaustion" do
195
195
  let(:handler){ Sidekiq::Middleware::Server::RetryJobs.new }
196
196
  let(:worker) { Minitest::Mock.new }
197
- let(:msg){ {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>Time.now.utc, "retry"=>3, "retry_count"=>3} }
197
+ let(:msg){ {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>Time.now.to_f, "retry"=>3, "retry_count"=>3} }
198
198
 
199
199
  describe "worker method" do
200
200
  let(:worker) do
@@ -210,7 +210,7 @@ class TestRetry < Sidekiq::Test
210
210
  end
211
211
 
212
212
  it 'calls worker.retries_exhausted after too many retries' do
213
- assert_equal [1,2, "foo", "retried_method"], handler.send(:retries_exhausted, worker.new, msg)
213
+ assert_equal [1,2, "foo", "retried_method"], handler.__send__(:retries_exhausted, worker.new, msg)
214
214
  end
215
215
  end
216
216
 
@@ -226,7 +226,7 @@ class TestRetry < Sidekiq::Test
226
226
  end
227
227
 
228
228
  it 'calls worker sidekiq_retries_exhausted_block after too many retries' do
229
- new_msg = handler.send(:retries_exhausted, worker.new, msg)
229
+ new_msg = handler.__send__(:retries_exhausted, worker.new, msg)
230
230
  expected_msg = msg.merge('called_by_callback' => true)
231
231
 
232
232
  assert_equal expected_msg, new_msg, "sidekiq_retries_exhausted block not called"
@@ -288,15 +288,15 @@ class TestRetry < Sidekiq::Test
288
288
  let(:handler) { Sidekiq::Middleware::Server::RetryJobs.new }
289
289
 
290
290
  it "retries with a default delay" do
291
- refute_equal 4, handler.send(:delay_for, worker, 2)
291
+ refute_equal 4, handler.__send__(:delay_for, worker, 2)
292
292
  end
293
293
 
294
294
  it "retries with a custom delay" do
295
- assert_equal 4, handler.send(:delay_for, custom_worker, 2)
295
+ assert_equal 4, handler.__send__(:delay_for, custom_worker, 2)
296
296
  end
297
297
 
298
298
  it "falls back to the default retry on exception" do
299
- refute_equal 4, handler.send(:delay_for, error_worker, 2)
299
+ refute_equal 4, handler.__send__(:delay_for, error_worker, 2)
300
300
  assert_match(/Failure scheduling retry using the defined `sidekiq_retry_in`/,
301
301
  File.read(@tmp_log_path), 'Log entry missing for sidekiq_retry_in')
302
302
  end
@@ -412,7 +412,7 @@ class TestWeb < Sidekiq::Test
412
412
  'error_message' => 'Some fake message',
413
413
  'error_class' => 'RuntimeError',
414
414
  'retry_count' => 0,
415
- 'failed_at' => Time.now.utc,
415
+ 'failed_at' => Time.now.to_f,
416
416
  'jid' => SecureRandom.hex(12) }
417
417
  score = Time.now.to_f
418
418
  Sidekiq.redis do |conn|
@@ -428,7 +428,7 @@ class TestWeb < Sidekiq::Test
428
428
  'error_message' => 'fail message: <a>hello</a>',
429
429
  'error_class' => 'RuntimeError',
430
430
  'retry_count' => 0,
431
- 'failed_at' => Time.now.utc,
431
+ 'failed_at' => Time.now.to_f,
432
432
  'jid' => SecureRandom.hex(12) }
433
433
  score = Time.now.to_f
434
434
  Sidekiq.redis do |conn|
@@ -2,7 +2,7 @@
2
2
  fr:
3
3
  Dashboard: Tableau de Bord
4
4
  Status: État
5
- Time: Temps
5
+ Time: Heure
6
6
  Namespace: Namespace
7
7
  Realtime: Temps Réel
8
8
  History: Historique
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: 2.17.4
4
+ version: 2.17.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-01 00:00:00.000000000 Z
11
+ date: 2014-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -123,21 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: actionmailer
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '>='
130
- - !ruby/object:Gem::Version
131
- version: 4.0.0
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '>='
137
- - !ruby/object:Gem::Version
138
- version: 4.0.0
139
- - !ruby/object:Gem::Dependency
140
- name: activerecord
126
+ name: rails
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - '>='