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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b589aea06c5a40ae600d780a9ae6eb89766d8195
4
- data.tar.gz: 0648e289e18aa26e8887bb5041a40fb2886080f5
3
+ metadata.gz: dea6136861d61b466dbeec68ffc57022140dddeb
4
+ data.tar.gz: a8eae3c0c21c3006571739e68f5978bffd1312c6
5
5
  SHA512:
6
- metadata.gz: 8f02a8ad25930c5123c8a6c52a0d173bd452e8442b6642fe02743ed7b5f1f29f791208dde1e4de257fe126e2909d072f934d28f5517334c350f87bcfab29eee9
7
- data.tar.gz: c28264360d2ddd2d0e868d17d8e3b0b8327f8cf6b84a3a845199be63bfb7d57ce2e85596d981da7e7abb8f71d6290b9ade4364ef8157ad99663edbfa1cdb24df
6
+ metadata.gz: a5c6decc852e45640a6b9526b38f1457fb75fe5fb439f53f0d30b8108f50c4817e20398833188ebfdbabc0f88e15f362654256f1ef3457f7ac2554ce083ff87a
7
+ data.tar.gz: 692dbde9798b2bca0d0db7c62cd47912ba43e6422ba2d159009715a904c9ca277875d69b7271aeefbc01be4f3c23e7a2ca7098a76843c97b027a31d46a34300b
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ coverage/
9
9
  vendor/
10
10
  .bundle/
11
11
  .sass-cache/
12
+ tmp/
@@ -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
- HEAD
1
+ 3.3.0
2
2
  -----------
3
3
 
4
- - Deprecate delay extension for ActionMailer 4.2+ . [#1933]
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
@@ -12,6 +12,10 @@ platforms :ruby do
12
12
  gem 'sqlite3'
13
13
  end
14
14
 
15
+ platforms :mri_21 do
16
+ gem 'pry-byebug'
17
+ end
18
+
15
19
  platforms :jruby do
16
20
  gem 'jruby-openssl'
17
21
  gem 'activerecord-jdbcsqlite3-adapter'
@@ -29,7 +29,7 @@ module Sidekiq
29
29
  template_file = File.join(
30
30
  'spec/workers',
31
31
  class_path,
32
- "#{file_name}_spec.rb"
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}_test.rb"
41
+ "#{file_name}_worker_test.rb"
42
42
  )
43
43
  template 'worker_test.rb.erb', template_file
44
44
  end
@@ -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
- def die(code)
199
- exit(code)
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)
@@ -17,9 +17,10 @@ module Sidekiq
17
17
  attr_reader :manager, :poller, :fetcher
18
18
 
19
19
  def initialize(options)
20
- @manager = Sidekiq::Manager.new_link options
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 @manager, options
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
- manager.wait(:shutdown) if manager.alive?
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.
@@ -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
- signal_shutdown
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
- signal_shutdown
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)
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "3.2.6"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -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.15.2'
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'
@@ -15,7 +15,7 @@ if ENV.has_key?("SIMPLECOV")
15
15
  end
16
16
 
17
17
  begin
18
- require 'pry'
18
+ require 'pry-byebug'
19
19
  rescue LoadError
20
20
  end
21
21
 
@@ -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
@@ -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 = Sidekiq::Manager.new(options)
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 = Sidekiq::Manager.new(options)
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 = Sidekiq::Manager.new(options)
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 = Sidekiq::Manager.new(options)
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 = Sidekiq::Manager.new(options)
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 = Sidekiq::Manager.new(options)
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 = Sidekiq::Manager.new(options)
99
+ @mgr = new_manager(options)
94
100
  @mgr.ready << @processor
95
101
  @mgr.assign(uow)
96
102
 
@@ -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.2.6
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-10-20 00:00:00.000000000 Z
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.15.2
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.15.2
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