sidekiq 3.2.6 → 3.3.0
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/.gitignore +1 -0
- data/.travis.yml +6 -0
- data/Changes.md +9 -2
- data/Gemfile +4 -0
- data/lib/generators/sidekiq/worker_generator.rb +2 -2
- data/lib/sidekiq/cli.rb +3 -3
- data/lib/sidekiq/launcher.rb +5 -3
- data/lib/sidekiq/manager.rb +4 -7
- data/lib/sidekiq/middleware/chain.rb +5 -0
- data/lib/sidekiq/version.rb +1 -1
- data/sidekiq.gemspec +1 -1
- data/test/helper.rb +1 -1
- data/test/test_cli.rb +2 -2
- data/test/test_manager.rb +13 -7
- data/test/test_middleware.rb +9 -0
- data/test/test_worker_generator.rb +17 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dea6136861d61b466dbeec68ffc57022140dddeb
|
4
|
+
data.tar.gz: a8eae3c0c21c3006571739e68f5978bffd1312c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5c6decc852e45640a6b9526b38f1457fb75fe5fb439f53f0d30b8108f50c4817e20398833188ebfdbabc0f88e15f362654256f1ef3457f7ac2554ce083ff87a
|
7
|
+
data.tar.gz: 692dbde9798b2bca0d0db7c62cd47912ba43e6422ba2d159009715a904c9ca277875d69b7271aeefbc01be4f3c23e7a2ca7098a76843c97b027a31d46a34300b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -8,5 +8,11 @@ rvm:
|
|
8
8
|
- 2.1
|
9
9
|
- 2.2
|
10
10
|
matrix:
|
11
|
+
global:
|
12
|
+
- BUNDLE_JOBS=4
|
11
13
|
allow_failures:
|
12
14
|
- rvm: rbx-2
|
15
|
+
before_install:
|
16
|
+
# Only use 1 job until Travis fixes the rbx --jobs issue.
|
17
|
+
- if [ "$TRAVIS_RUBY_VERSION" == "rbx-2" ] ; then export BUNDLE_JOBS=1 ; fi
|
18
|
+
install: bundle install --retry=3
|
data/Changes.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
|
1
|
+
3.3.0
|
2
2
|
-----------
|
3
3
|
|
4
|
-
-
|
4
|
+
- Upgrade to Celluloid 0.16 [#2056]
|
5
|
+
- Fix typo for generator test file name [dlackty, #2016]
|
6
|
+
- Add Sidekiq::Middleware::Chain#prepend [seuros, #2029]
|
7
|
+
|
8
|
+
3.2.6
|
9
|
+
-----------
|
10
|
+
|
11
|
+
- Deprecate delay extension for ActionMailer 4.2+ . [seuros, #1933]
|
5
12
|
- Poll interval tuning now accounts for dead processes [epchris, #1984]
|
6
13
|
- Add non-production environment to Web UI page titles [JacobEvelyn, #2004]
|
7
14
|
|
data/Gemfile
CHANGED
@@ -29,7 +29,7 @@ module Sidekiq
|
|
29
29
|
template_file = File.join(
|
30
30
|
'spec/workers',
|
31
31
|
class_path,
|
32
|
-
"#{file_name}
|
32
|
+
"#{file_name}_worker_spec.rb"
|
33
33
|
)
|
34
34
|
template 'worker_spec.rb.erb', template_file
|
35
35
|
end
|
@@ -38,7 +38,7 @@ module Sidekiq
|
|
38
38
|
template_file = File.join(
|
39
39
|
'test/workers',
|
40
40
|
class_path,
|
41
|
-
"#{file_name}
|
41
|
+
"#{file_name}_worker_test.rb"
|
42
42
|
)
|
43
43
|
template 'worker_test.rb.erb', template_file
|
44
44
|
end
|
data/lib/sidekiq/cli.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
$stdout.sync = true
|
2
3
|
|
3
4
|
require 'yaml'
|
@@ -195,9 +196,8 @@ module Sidekiq
|
|
195
196
|
@environment = cli_env || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
196
197
|
end
|
197
198
|
|
198
|
-
|
199
|
-
|
200
|
-
end
|
199
|
+
alias_method :die, :exit
|
200
|
+
alias_method :☠, :exit
|
201
201
|
|
202
202
|
def setup_options(args)
|
203
203
|
opts = parse_options(args)
|
data/lib/sidekiq/launcher.rb
CHANGED
@@ -17,9 +17,10 @@ module Sidekiq
|
|
17
17
|
attr_reader :manager, :poller, :fetcher
|
18
18
|
|
19
19
|
def initialize(options)
|
20
|
-
@
|
20
|
+
@condvar = Celluloid::Condition.new
|
21
|
+
@manager = Sidekiq::Manager.new_link(@condvar, options)
|
21
22
|
@poller = Sidekiq::Scheduled::Poller.new_link
|
22
|
-
@fetcher = Sidekiq::Fetcher.new_link
|
23
|
+
@fetcher = Sidekiq::Fetcher.new_link(@manager, options)
|
23
24
|
@manager.fetcher = @fetcher
|
24
25
|
@done = false
|
25
26
|
@options = options
|
@@ -49,7 +50,8 @@ module Sidekiq
|
|
49
50
|
poller.terminate if poller.alive?
|
50
51
|
|
51
52
|
manager.async.stop(:shutdown => true, :timeout => @options[:timeout])
|
52
|
-
|
53
|
+
@condvar.wait
|
54
|
+
manager.terminate
|
53
55
|
|
54
56
|
# Requeue everything in case there was a worker who grabbed work while stopped
|
55
57
|
# This call is a no-op in Sidekiq but necessary for Sidekiq Pro.
|
data/lib/sidekiq/manager.rb
CHANGED
@@ -22,11 +22,12 @@ module Sidekiq
|
|
22
22
|
|
23
23
|
SPIN_TIME_FOR_GRACEFUL_SHUTDOWN = 1
|
24
24
|
|
25
|
-
def initialize(options={})
|
25
|
+
def initialize(condvar, options={})
|
26
26
|
logger.debug { options.inspect }
|
27
27
|
@options = options
|
28
28
|
@count = options[:concurrency] || 25
|
29
29
|
@done_callback = nil
|
30
|
+
@finished = condvar
|
30
31
|
|
31
32
|
@in_progress = {}
|
32
33
|
@threads = {}
|
@@ -183,7 +184,7 @@ module Sidekiq
|
|
183
184
|
end
|
184
185
|
end
|
185
186
|
|
186
|
-
|
187
|
+
@finished.signal
|
187
188
|
end
|
188
189
|
end
|
189
190
|
end
|
@@ -204,11 +205,7 @@ module Sidekiq
|
|
204
205
|
|
205
206
|
def shutdown
|
206
207
|
requeue
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
def signal_shutdown
|
211
|
-
after(0) { signal(:shutdown) }
|
208
|
+
@finished.signal
|
212
209
|
end
|
213
210
|
|
214
211
|
def requeue
|
@@ -89,6 +89,11 @@ module Sidekiq
|
|
89
89
|
entries << Entry.new(klass, *args)
|
90
90
|
end
|
91
91
|
|
92
|
+
def prepend(klass, *args)
|
93
|
+
remove(klass) if exists?(klass)
|
94
|
+
entries.insert(0, Entry.new(klass, *args))
|
95
|
+
end
|
96
|
+
|
92
97
|
def insert_before(oldklass, newklass, *args)
|
93
98
|
i = entries.index { |entry| entry.klass == newklass }
|
94
99
|
new_entry = i.nil? ? Entry.new(newklass, *args) : entries.delete_at(i)
|
data/lib/sidekiq/version.rb
CHANGED
data/sidekiq.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.add_dependency 'redis', '>= 3.0.6'
|
18
18
|
gem.add_dependency 'redis-namespace', '>= 1.3.1'
|
19
19
|
gem.add_dependency 'connection_pool', '>= 2.0.0'
|
20
|
-
gem.add_dependency 'celluloid', '0.
|
20
|
+
gem.add_dependency 'celluloid', '>= 0.16.0'
|
21
21
|
gem.add_dependency 'json'
|
22
22
|
gem.add_development_dependency 'sinatra'
|
23
23
|
gem.add_development_dependency 'minitest', '~> 5.3.3'
|
data/test/helper.rb
CHANGED
data/test/test_cli.rb
CHANGED
@@ -31,9 +31,9 @@ class TestCli < Sidekiq::Test
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'does not boot rails' do
|
34
|
-
refute defined?(::Rails)
|
34
|
+
refute defined?(::Rails::Application)
|
35
35
|
@cli.parse(['sidekiq', '-r', './myapp'])
|
36
|
-
refute defined?(::Rails)
|
36
|
+
refute defined?(::Rails::Application)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'changes concurrency' do
|
data/test/test_manager.rb
CHANGED
@@ -9,8 +9,14 @@ class TestManager < Sidekiq::Test
|
|
9
9
|
Sidekiq.redis {|c| c.flushdb }
|
10
10
|
end
|
11
11
|
|
12
|
+
def new_manager(opts)
|
13
|
+
condvar = Minitest::Mock.new
|
14
|
+
condvar.expect(:signal, nil, [])
|
15
|
+
Sidekiq::Manager.new(condvar, opts)
|
16
|
+
end
|
17
|
+
|
12
18
|
it 'creates N processor instances' do
|
13
|
-
mgr =
|
19
|
+
mgr = new_manager(options)
|
14
20
|
assert_equal options[:concurrency], mgr.ready.size
|
15
21
|
assert_equal [], mgr.busy
|
16
22
|
end
|
@@ -21,7 +27,7 @@ class TestManager < Sidekiq::Test
|
|
21
27
|
processor.expect(:async, processor, [])
|
22
28
|
processor.expect(:process, nil, [uow])
|
23
29
|
|
24
|
-
mgr =
|
30
|
+
mgr = new_manager(options)
|
25
31
|
mgr.ready << processor
|
26
32
|
mgr.assign(uow)
|
27
33
|
assert_equal 1, mgr.busy.size
|
@@ -33,7 +39,7 @@ class TestManager < Sidekiq::Test
|
|
33
39
|
uow = Minitest::Mock.new
|
34
40
|
uow.expect(:requeue, nil, [])
|
35
41
|
|
36
|
-
mgr =
|
42
|
+
mgr = new_manager(options)
|
37
43
|
mgr.fetcher = Sidekiq::BasicFetch.new({:queues => []})
|
38
44
|
mgr.stop
|
39
45
|
mgr.assign(uow)
|
@@ -41,7 +47,7 @@ class TestManager < Sidekiq::Test
|
|
41
47
|
end
|
42
48
|
|
43
49
|
it 'shuts down the system' do
|
44
|
-
mgr =
|
50
|
+
mgr = new_manager(options)
|
45
51
|
mgr.fetcher = Sidekiq::BasicFetch.new({:queues => []})
|
46
52
|
mgr.stop
|
47
53
|
|
@@ -53,7 +59,7 @@ class TestManager < Sidekiq::Test
|
|
53
59
|
fetcher = MiniTest::Mock.new
|
54
60
|
fetcher.expect :async, fetcher, []
|
55
61
|
fetcher.expect :fetch, nil, []
|
56
|
-
mgr =
|
62
|
+
mgr = new_manager(options)
|
57
63
|
mgr.fetcher = fetcher
|
58
64
|
init_size = mgr.ready.size
|
59
65
|
processor = mgr.ready.pop
|
@@ -69,7 +75,7 @@ class TestManager < Sidekiq::Test
|
|
69
75
|
fetcher = MiniTest::Mock.new
|
70
76
|
fetcher.expect :async, fetcher, []
|
71
77
|
fetcher.expect :fetch, nil, []
|
72
|
-
mgr =
|
78
|
+
mgr = new_manager(options)
|
73
79
|
mgr.fetcher = fetcher
|
74
80
|
init_size = mgr.ready.size
|
75
81
|
processor = mgr.ready.pop
|
@@ -90,7 +96,7 @@ class TestManager < Sidekiq::Test
|
|
90
96
|
@processor.expect(:async, @processor, [])
|
91
97
|
@processor.expect(:process, nil, [uow])
|
92
98
|
|
93
|
-
@mgr =
|
99
|
+
@mgr = new_manager(options)
|
94
100
|
@mgr.ready << @processor
|
95
101
|
@mgr.assign(uow)
|
96
102
|
|
data/test/test_middleware.rb
CHANGED
@@ -96,6 +96,15 @@ class TestMiddleware < Sidekiq::Test
|
|
96
96
|
assert_equal 1, chain.count
|
97
97
|
end
|
98
98
|
|
99
|
+
it 'correctly prepends middleware' do
|
100
|
+
chain = Sidekiq::Middleware::Chain.new
|
101
|
+
chain_entries = chain.entries
|
102
|
+
chain.add CustomMiddleware
|
103
|
+
chain.prepend YetAnotherCustomMiddleware
|
104
|
+
assert_equal YetAnotherCustomMiddleware, chain_entries.first.klass
|
105
|
+
assert_equal CustomMiddleware, chain_entries.last.klass
|
106
|
+
end
|
107
|
+
|
99
108
|
it 'allows middleware to abruptly stop processing rest of chain' do
|
100
109
|
recorder = []
|
101
110
|
chain = Sidekiq::Middleware::Chain.new
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'rails/generators/test_case'
|
3
|
+
require 'generators/sidekiq/worker_generator'
|
4
|
+
|
5
|
+
class WorkerGeneratorTest < Rails::Generators::TestCase
|
6
|
+
tests Sidekiq::Generators::WorkerGenerator
|
7
|
+
arguments %w(foo)
|
8
|
+
destination File.expand_path("../tmp", File.dirname(__FILE__))
|
9
|
+
setup :prepare_destination
|
10
|
+
|
11
|
+
test "worker is created and its test" do
|
12
|
+
run_generator
|
13
|
+
|
14
|
+
assert_file "app/workers/foo_worker.rb"
|
15
|
+
assert_file "test/workers/foo_worker_test.rb"
|
16
|
+
end
|
17
|
+
end
|
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: 3.
|
4
|
+
version: 3.3.0
|
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-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: celluloid
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.16.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.16.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- test/test_testing_fake.rb
|
233
233
|
- test/test_testing_inline.rb
|
234
234
|
- test/test_web.rb
|
235
|
+
- test/test_worker_generator.rb
|
235
236
|
- web/assets/images/bootstrap/glyphicons-halflings-white.png
|
236
237
|
- web/assets/images/bootstrap/glyphicons-halflings.png
|
237
238
|
- web/assets/images/logo.png
|
@@ -372,3 +373,4 @@ test_files:
|
|
372
373
|
- test/test_testing_fake.rb
|
373
374
|
- test/test_testing_inline.rb
|
374
375
|
- test/test_web.rb
|
376
|
+
- test/test_worker_generator.rb
|