mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge branch 'master' into 5-0
This commit is contained in:
commit
bca4f2b224
13 changed files with 23 additions and 21 deletions
|
@ -9,4 +9,5 @@ before_install:
|
||||||
rvm:
|
rvm:
|
||||||
- 2.2.4
|
- 2.2.4
|
||||||
- 2.3.0
|
- 2.3.0
|
||||||
- jruby-head
|
- 2.4.0
|
||||||
|
- jruby-9.1.6.0
|
||||||
|
|
4
Gemfile
4
Gemfile
|
@ -1,11 +1,11 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem 'rails', '5.0.0'
|
gem 'rails', '>= 5.0.1'
|
||||||
gem "hiredis"
|
gem "hiredis"
|
||||||
gem 'simplecov'
|
gem 'simplecov'
|
||||||
gem 'minitest'
|
gem 'minitest'
|
||||||
gem 'minitest-utils'
|
#gem 'minitest-utils'
|
||||||
gem 'toxiproxy'
|
gem 'toxiproxy'
|
||||||
|
|
||||||
platforms :rbx do
|
platforms :rbx do
|
||||||
|
|
|
@ -142,7 +142,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
when 'TTIN'
|
when 'TTIN'
|
||||||
Thread.list.each do |thread|
|
Thread.list.each do |thread|
|
||||||
Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
|
Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['sidekiq_label']}"
|
||||||
if thread.backtrace
|
if thread.backtrace
|
||||||
Sidekiq.logger.warn thread.backtrace.join("\n")
|
Sidekiq.logger.warn thread.backtrace.join("\n")
|
||||||
else
|
else
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Sidekiq
|
||||||
|
|
||||||
##
|
##
|
||||||
# The Manager is the central coordination point in Sidekiq, controlling
|
# The Manager is the central coordination point in Sidekiq, controlling
|
||||||
# the lifecycle of the Processors and feeding them jobs as necessary.
|
# the lifecycle of the Processors.
|
||||||
#
|
#
|
||||||
# Tasks:
|
# Tasks:
|
||||||
#
|
#
|
||||||
|
|
|
@ -162,7 +162,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def retry_attempts_from(msg_retry, default)
|
def retry_attempts_from(msg_retry, default)
|
||||||
if msg_retry.is_a?(Fixnum)
|
if msg_retry.is_a?(Integer)
|
||||||
msg_retry
|
msg_retry
|
||||||
else
|
else
|
||||||
default
|
default
|
||||||
|
|
|
@ -22,6 +22,7 @@ module Sidekiq
|
||||||
|
|
||||||
def safe_thread(name, &block)
|
def safe_thread(name, &block)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
|
Thread.current['sidekiq_label'] = name
|
||||||
watchdog(name, &block)
|
watchdog(name, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -274,7 +274,7 @@ module Sidekiq
|
||||||
resp = case resp
|
resp = case resp
|
||||||
when Array
|
when Array
|
||||||
resp
|
resp
|
||||||
when Fixnum
|
when Integer
|
||||||
[resp, {}, []]
|
[resp, {}, []]
|
||||||
else
|
else
|
||||||
type_header = case action.type
|
type_header = case action.type
|
||||||
|
|
|
@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
||||||
gem.add_dependency 'concurrent-ruby', '~> 1.0'
|
gem.add_dependency 'concurrent-ruby', '~> 1.0'
|
||||||
gem.add_dependency 'rack-protection', '>= 1.5.0'
|
gem.add_dependency 'rack-protection', '>= 1.5.0'
|
||||||
gem.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
|
gem.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
|
||||||
gem.add_development_dependency 'minitest', '~> 5.7', '>= 5.7.0'
|
gem.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.1'
|
||||||
gem.add_development_dependency 'rake', '~> 10.0'
|
gem.add_development_dependency 'rake', '~> 10.0'
|
||||||
gem.add_development_dependency 'rails', '>= 3.2.0'
|
gem.add_development_dependency 'rails', '>= 3.2.0'
|
||||||
end
|
end
|
||||||
|
|
|
@ -185,7 +185,7 @@ class TestCli < Sidekiq::Test
|
||||||
assert_equal './test/config.yml', Sidekiq.options[:config_file]
|
assert_equal './test/config.yml', Sidekiq.options[:config_file]
|
||||||
refute Sidekiq.options[:verbose]
|
refute Sidekiq.options[:verbose]
|
||||||
assert_equal './test/fake_env.rb', Sidekiq.options[:require]
|
assert_equal './test/fake_env.rb', Sidekiq.options[:require]
|
||||||
assert_equal nil, Sidekiq.options[:environment]
|
assert_nil Sidekiq.options[:environment]
|
||||||
assert_equal 50, Sidekiq.options[:concurrency]
|
assert_equal 50, Sidekiq.options[:concurrency]
|
||||||
assert_equal '/tmp/sidekiq-config-test.pid', Sidekiq.options[:pidfile]
|
assert_equal '/tmp/sidekiq-config-test.pid', Sidekiq.options[:pidfile]
|
||||||
assert_equal '/tmp/sidekiq.log', Sidekiq.options[:logfile]
|
assert_equal '/tmp/sidekiq.log', Sidekiq.options[:logfile]
|
||||||
|
@ -373,7 +373,7 @@ class TestCli < Sidekiq::Test
|
||||||
@tmp_log_path = '/tmp/sidekiq.log'
|
@tmp_log_path = '/tmp/sidekiq.log'
|
||||||
@cli.parse(['sidekiq', '-L', @tmp_log_path, '-r', './test/fake_env.rb'])
|
@cli.parse(['sidekiq', '-L', @tmp_log_path, '-r', './test/fake_env.rb'])
|
||||||
@mock_thread = MiniTest::Mock.new
|
@mock_thread = MiniTest::Mock.new
|
||||||
@mock_thread.expect(:[], 'interrupt_test', ['label'])
|
@mock_thread.expect(:[], 'interrupt_test', ['sidekiq_label'])
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -159,7 +159,7 @@ class TestClient < Sidekiq::Test
|
||||||
chain.add Stopper
|
chain.add Stopper
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal nil, client.push('class' => MyWorker, 'args' => [0])
|
assert_nil client.push('class' => MyWorker, 'args' => [0])
|
||||||
assert_match(/[0-9a-f]{12}/, client.push('class' => MyWorker, 'args' => [1]))
|
assert_match(/[0-9a-f]{12}/, client.push('class' => MyWorker, 'args' => [1]))
|
||||||
client.push_bulk('class' => MyWorker, 'args' => [[0], [1]]).each do |jid|
|
client.push_bulk('class' => MyWorker, 'args' => [[0], [1]]).each do |jid|
|
||||||
assert_match(/[0-9a-f]{12}/, jid)
|
assert_match(/[0-9a-f]{12}/, jid)
|
||||||
|
|
|
@ -5,30 +5,30 @@ require 'sidekiq/logging'
|
||||||
class TestLogging < Sidekiq::Test
|
class TestLogging < Sidekiq::Test
|
||||||
describe Sidekiq::Logging do
|
describe Sidekiq::Logging do
|
||||||
describe "#with_context" do
|
describe "#with_context" do
|
||||||
def context
|
def ctx
|
||||||
Sidekiq::Logging.logger.formatter.context
|
Sidekiq::Logging.logger.formatter.context
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has no context by default" do
|
it "has no context by default" do
|
||||||
context.must_equal nil
|
assert_nil ctx
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can add a context" do
|
it "can add a context" do
|
||||||
Sidekiq::Logging.with_context "xx" do
|
Sidekiq::Logging.with_context "xx" do
|
||||||
context.must_equal " xx"
|
assert_equal " xx", ctx
|
||||||
end
|
end
|
||||||
context.must_equal nil
|
assert_nil ctx
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can use multiple contexts" do
|
it "can use multiple contexts" do
|
||||||
Sidekiq::Logging.with_context "xx" do
|
Sidekiq::Logging.with_context "xx" do
|
||||||
context.must_equal " xx"
|
assert_equal " xx", ctx
|
||||||
Sidekiq::Logging.with_context "yy" do
|
Sidekiq::Logging.with_context "yy" do
|
||||||
context.must_equal " xx yy"
|
assert_equal " xx yy", ctx
|
||||||
end
|
end
|
||||||
context.must_equal " xx"
|
assert_equal " xx", ctx
|
||||||
end
|
end
|
||||||
context.must_equal nil
|
assert_nil ctx
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -112,7 +112,7 @@ class TestMiddleware < Sidekiq::Test
|
||||||
|
|
||||||
final_action = nil
|
final_action = nil
|
||||||
chain.invoke { final_action = true }
|
chain.invoke { final_action = true }
|
||||||
assert_equal nil, final_action
|
assert_nil final_action
|
||||||
assert_equal [], recorder
|
assert_equal [], recorder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,7 +117,7 @@ class TestRetryExhausted < Sidekiq::Test
|
||||||
|
|
||||||
assert old_worker.exhausted_called?
|
assert old_worker.exhausted_called?
|
||||||
assert_equal raised_error.message, old_worker.exhausted_job['error_message']
|
assert_equal raised_error.message, old_worker.exhausted_job['error_message']
|
||||||
assert_equal nil, new_worker.exhausted_exception
|
assert_nil new_worker.exhausted_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows a global default handler' do
|
it 'allows a global default handler' do
|
||||||
|
|
Loading…
Reference in a new issue