sidekiq-limit_fetch 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 308521ae4ca41ec67f93b1e586c24d5b2704c6f2
4
- data.tar.gz: 638d54dc481262e7bf13a128777cd22016106a3d
3
+ metadata.gz: 1edc411f8e5b3ab852b0b005548a28fafd0167e4
4
+ data.tar.gz: df6b938724aa978eab9757d1c969c9577c9e58c3
5
5
  SHA512:
6
- metadata.gz: 6a584f739cc6c4c825a6c1da2e09aec8536ca866433605252220b503bc3fbabe75a35228053b4ba38656c7016b24aa466272c321cc0d1bd41eb04829c5e0f7f7
7
- data.tar.gz: d62381535352afec36b7668792f0db79d069ec4b10ab0ede19dc7d6c69720a21612265338192ecd4f693e08a0bcc21d988b5e20bd47b025b38035a3a1fefbd0e
6
+ metadata.gz: 4cb020c997e1dc814969e949ae497f49ee048f4d8b0b18833dd8eca51de0a1b943cae09d2e34e523e9d9c29b251101bf707cbab67d7a5ff270cda43be69ffbbd
7
+ data.tar.gz: 29eb71b1e70bde0da6dee13798e2fae39c2900abca6cbcf25d22ab2466028525ef84ff4abb3c00b02b48524b4ffef09bb8a98f432761d9e5081bf3a656c7d24e
@@ -9,8 +9,8 @@ class Sidekiq::LimitFetch
9
9
 
10
10
  options[:strict] ? strict_order! : weighted_order!
11
11
 
12
- set :limit, options[:limits]
13
12
  set :process_limit, options[:process_limits]
13
+ set :limit, options[:limits]
14
14
  set_blocks options[:blocking]
15
15
  end
16
16
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '2.4.1'
3
+ gem.version = '2.4.2'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = 'brainopia'
6
6
  gem.email = 'brainopia@evilmartians.com'
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = %w(lib)
17
17
 
18
18
  gem.add_dependency 'sidekiq', '>= 2.6.5', '< 4.0'
19
- gem.add_development_dependency 'rspec', '< 3.0'
19
+ gem.add_development_dependency 'rspec', '~> 3.2.0'
20
20
  gem.add_development_dependency 'rake'
21
21
  end
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Sidekiq::Queue do
3
+ RSpec.describe Sidekiq::Queue do
4
4
  context 'singleton' do
5
5
  shared_examples :constructor do
6
6
  it 'with default name' do
7
7
  new_object = -> { described_class.send constructor }
8
- new_object.call.should == new_object.call
8
+ expect(new_object.call).to eq new_object.call
9
9
  end
10
10
 
11
11
  it 'with given name' do
12
12
  new_object = ->(name) { described_class.send constructor, name }
13
- new_object.call('name').should == new_object.call('name')
13
+ expect(new_object.call('name')).to eq new_object.call('name')
14
14
  end
15
15
  end
16
16
 
@@ -29,67 +29,67 @@ describe Sidekiq::Queue do
29
29
  let(:queue) { Sidekiq::Queue[name] }
30
30
 
31
31
  it 'should be available' do
32
- queue.acquire.should be
32
+ expect(queue.acquire).to be
33
33
  end
34
34
 
35
35
  it 'should be pausable' do
36
36
  queue.pause
37
- queue.acquire.should_not be
37
+ expect(queue.acquire).not_to be
38
38
  end
39
39
 
40
40
  it 'should be continuable' do
41
41
  queue.pause
42
42
  queue.unpause
43
- queue.acquire.should be
43
+ expect(queue.acquire).to be
44
44
  end
45
45
 
46
46
  it 'should be limitable' do
47
47
  queue.limit = 1
48
- queue.acquire.should be
49
- queue.acquire.should_not be
48
+ expect(queue.acquire).to be
49
+ expect(queue.acquire).not_to be
50
50
  end
51
51
 
52
52
  it 'should be resizable' do
53
53
  queue.limit = 0
54
- queue.acquire.should_not be
54
+ expect(queue.acquire).not_to be
55
55
  queue.limit = nil
56
- queue.acquire.should be
56
+ expect(queue.acquire).to be
57
57
  end
58
58
 
59
59
  it 'should be countable' do
60
60
  queue.limit = 3
61
61
  5.times { queue.acquire }
62
- queue.probed.should == 3
62
+ expect(queue.probed).to eq 3
63
63
  end
64
64
 
65
65
  it 'should be releasable' do
66
66
  queue.acquire
67
- queue.probed.should == 1
67
+ expect(queue.probed).to eq 1
68
68
  queue.release
69
- queue.probed.should == 0
69
+ expect(queue.probed).to eq 0
70
70
  end
71
71
 
72
72
  it 'should tell if paused' do
73
- queue.should_not be_paused
73
+ expect(queue).not_to be_paused
74
74
  queue.pause
75
- queue.should be_paused
75
+ expect(queue).to be_paused
76
76
  queue.unpause
77
- queue.should_not be_paused
77
+ expect(queue).not_to be_paused
78
78
  end
79
79
 
80
80
  it 'should tell if blocking' do
81
- queue.should_not be_blocking
81
+ expect(queue).not_to be_blocking
82
82
  queue.block
83
- queue.should be_blocking
83
+ expect(queue).to be_blocking
84
84
  queue.unblock
85
- queue.should_not be_blocking
85
+ expect(queue).not_to be_blocking
86
86
  end
87
87
 
88
88
  it 'should be marked as changed' do
89
89
  queue = Sidekiq::Queue["uniq_#{name}"]
90
- queue.should_not be_limit_changed
90
+ expect(queue).not_to be_limit_changed
91
91
  queue.limit = 3
92
- queue.should be_limit_changed
92
+ expect(queue).to be_limit_changed
93
93
  end
94
94
  end
95
95
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  Thread.abort_on_exception = true
4
4
 
5
- describe Sidekiq::LimitFetch::Global::Monitor do
5
+ RSpec.describe Sidekiq::LimitFetch::Global::Monitor do
6
6
  let(:queues) { double dynamic?: false }
7
7
  let(:monitor) { described_class.start! queues, ttl, timeout }
8
8
  let(:ttl) { 1 }
@@ -23,21 +23,21 @@ describe Sidekiq::LimitFetch::Global::Monitor do
23
23
  it 'should remove invalidated old locks' do
24
24
  2.times { queue.acquire }
25
25
  sleep 2*ttl
26
- queue.probed.should == 2
26
+ expect(queue.probed).to eq 2
27
27
 
28
- described_class.stub :update_heartbeat
28
+ allow(described_class).to receive(:update_heartbeat)
29
29
  sleep 2*ttl
30
- queue.probed.should == 0
30
+ expect(queue.probed).to eq 0
31
31
  end
32
32
 
33
33
  it 'should remove invalid locks' do
34
34
  2.times { queue.acquire }
35
- described_class.stub :update_heartbeat
35
+ allow(described_class).to receive(:update_heartbeat)
36
36
  Sidekiq.redis do |it|
37
37
  it.del Sidekiq::LimitFetch::Global::Monitor::PROCESS_SET
38
38
  end
39
39
  sleep 2*ttl
40
- queue.probed.should == 0
40
+ expect(queue.probed).to eq 0
41
41
  end
42
42
  end
43
43
  end
@@ -1,69 +1,71 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Sidekiq::LimitFetch::Queues do
3
+ RSpec.describe Sidekiq::LimitFetch::Queues do
4
4
  subject { described_class.new options }
5
5
 
6
- let(:queues) { %w[queue1 queue2] }
7
- let(:limits) {{ 'queue1' => 3 }}
8
- let(:strict) { true }
9
- let(:blocking) {}
6
+ let(:queues) { %w[queue1 queue2] }
7
+ let(:limits) {{ 'queue1' => 3 }}
8
+ let(:strict) { true }
9
+ let(:blocking) {}
10
+ let(:process_limits) {{ 'queue2' => 3 }}
10
11
 
11
12
  let(:options) do
12
13
  { queues: queues,
13
14
  limits: limits,
14
15
  strict: strict,
15
16
  blocking: blocking,
17
+ process_limits: process_limits,
16
18
  namespace: Sidekiq::LimitFetch::Redis.determine_namespace }
17
19
  end
18
20
 
19
21
  it 'should acquire queues' do
20
22
  subject.acquire
21
- Sidekiq::Queue['queue1'].probed.should == 1
22
- Sidekiq::Queue['queue2'].probed.should == 1
23
+ expect(Sidekiq::Queue['queue1'].probed).to eq 1
24
+ expect(Sidekiq::Queue['queue2'].probed).to eq 1
23
25
  end
24
26
 
25
27
  it 'should acquire dynamically blocking queues' do
26
28
  subject.acquire
27
- Sidekiq::Queue['queue1'].probed.should == 1
28
- Sidekiq::Queue['queue2'].probed.should == 1
29
+ expect(Sidekiq::Queue['queue1'].probed).to eq 1
30
+ expect(Sidekiq::Queue['queue2'].probed).to eq 1
29
31
 
30
32
  Sidekiq::Queue['queue1'].block
31
33
 
32
34
  subject.acquire
33
- Sidekiq::Queue['queue1'].probed.should == 2
34
- Sidekiq::Queue['queue2'].probed.should == 1
35
+ expect(Sidekiq::Queue['queue1'].probed).to eq 2
36
+ expect(Sidekiq::Queue['queue2'].probed).to eq 1
35
37
  end
36
38
 
37
39
  it 'should block except given queues' do
38
40
  Sidekiq::Queue['queue1'].block_except 'queue2'
39
41
  subject.acquire
40
- Sidekiq::Queue['queue1'].probed.should == 1
41
- Sidekiq::Queue['queue2'].probed.should == 1
42
+ expect(Sidekiq::Queue['queue1'].probed).to eq 1
43
+ expect(Sidekiq::Queue['queue2'].probed).to eq 1
42
44
 
43
45
  Sidekiq::Queue['queue1'].block_except 'queue404'
44
46
  subject.acquire
45
- Sidekiq::Queue['queue1'].probed.should == 2
46
- Sidekiq::Queue['queue2'].probed.should == 1
47
+ expect(Sidekiq::Queue['queue1'].probed).to eq 2
48
+ expect(Sidekiq::Queue['queue2'].probed).to eq 1
47
49
  end
48
50
 
49
51
  it 'should release queues' do
50
52
  subject.acquire
51
53
  subject.release_except nil
52
- Sidekiq::Queue['queue1'].probed.should == 0
53
- Sidekiq::Queue['queue2'].probed.should == 0
54
+ expect(Sidekiq::Queue['queue1'].probed).to eq 0
55
+ expect(Sidekiq::Queue['queue2'].probed).to eq 0
54
56
  end
55
57
 
56
58
  it 'should release queues except selected' do
57
59
  subject.acquire
58
60
  subject.release_except 'queue:queue1'
59
- Sidekiq::Queue['queue1'].probed.should == 1
60
- Sidekiq::Queue['queue2'].probed.should == 0
61
+ expect(Sidekiq::Queue['queue1'].probed).to eq 1
62
+ expect(Sidekiq::Queue['queue2'].probed).to eq 0
61
63
  end
62
64
 
63
65
  it 'should release when no queues was acquired' do
64
66
  queues.each {|name| Sidekiq::Queue[name].pause }
65
67
  subject.acquire
66
- -> { subject.release_except nil }.should_not raise_exception
68
+ expect { subject.release_except nil }.not_to raise_exception
67
69
  end
68
70
 
69
71
  context 'blocking' do
@@ -71,26 +73,31 @@ describe Sidekiq::LimitFetch::Queues do
71
73
 
72
74
  it 'should acquire blocking queues' do
73
75
  3.times { subject.acquire }
74
- Sidekiq::Queue['queue1'].probed.should == 3
75
- Sidekiq::Queue['queue2'].probed.should == 1
76
+ expect(Sidekiq::Queue['queue1'].probed).to eq 3
77
+ expect(Sidekiq::Queue['queue2'].probed).to eq 1
76
78
  end
77
79
  end
78
80
 
79
81
  it 'should set limits' do
80
82
  subject
81
- Sidekiq::Queue['queue1'].limit.should == 3
82
- Sidekiq::Queue['queue2'].limit.should_not be
83
+ expect(Sidekiq::Queue['queue1'].limit).to eq 3
84
+ expect(Sidekiq::Queue['queue2'].limit).not_to be
85
+ end
86
+
87
+ it 'should set process_limits' do
88
+ subject
89
+ expect(Sidekiq::Queue['queue2'].process_limit).to eq 3
83
90
  end
84
91
 
85
92
  context 'without strict flag' do
86
93
  let(:strict) { false }
87
94
 
88
95
  it 'should retrieve weighted queues' do
89
- subject.ordered_queues.should =~ %w(queue1 queue2)
96
+ expect(subject.ordered_queues).to match_array(%w(queue1 queue2))
90
97
  end
91
98
  end
92
99
 
93
100
  it 'with strict flag should retrieve strictly ordered queues' do
94
- subject.ordered_queues.should == %w(queue1 queue2)
101
+ expect(subject.ordered_queues).to eq %w(queue1 queue2)
95
102
  end
96
103
  end
@@ -1,48 +1,48 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'semaphore' do
3
+ RSpec.describe 'semaphore' do
4
4
  let(:name) { 'default' }
5
5
  subject { Sidekiq::LimitFetch::Global::Semaphore.new name }
6
6
 
7
7
  it 'should have no limit by default' do
8
- subject.limit.should_not be
8
+ expect(subject.limit).not_to be
9
9
  end
10
10
 
11
11
  it 'should set limit' do
12
12
  subject.limit = 4
13
- subject.limit.should == 4
13
+ expect(subject.limit).to eq 4
14
14
  end
15
15
 
16
16
  it 'should acquire and count active tasks' do
17
17
  3.times { subject.acquire }
18
- subject.probed.should == 3
18
+ expect(subject.probed).to eq 3
19
19
  end
20
20
 
21
21
  it 'should acquire tasks with regard to limit' do
22
22
  subject.limit = 4
23
23
  6.times { subject.acquire }
24
- subject.probed.should == 4
24
+ expect(subject.probed).to eq 4
25
25
  end
26
26
 
27
27
  it 'should acquire tasks with regard to process limit' do
28
28
  subject.process_limit = 4
29
29
  6.times { subject.acquire }
30
- subject.probed.should == 4
30
+ expect(subject.probed).to eq 4
31
31
  end
32
32
 
33
33
  it 'should release active tasks' do
34
34
  6.times { subject.acquire }
35
35
  3.times { subject.release }
36
- subject.probed.should == 3
36
+ expect(subject.probed).to eq 3
37
37
  end
38
38
 
39
39
  it 'should pause tasks' do
40
40
  3.times { subject.acquire }
41
41
  subject.pause
42
42
  2.times { subject.acquire }
43
- subject.probed.should == 3
43
+ expect(subject.probed).to eq 3
44
44
  2.times { subject.release }
45
- subject.probed.should == 1
45
+ expect(subject.probed).to eq 1
46
46
  end
47
47
 
48
48
  it 'should unpause tasks' do
@@ -50,16 +50,16 @@ describe 'semaphore' do
50
50
  3.times { subject.acquire }
51
51
  subject.unpause
52
52
  2.times { subject.acquire }
53
- subject.probed.should == 2
53
+ expect(subject.probed).to eq 2
54
54
  end
55
55
 
56
56
  it 'should pause tasks for a limited time' do
57
57
  3.times { subject.acquire }
58
58
  subject.pause_for_ms 50
59
59
  2.times { subject.acquire }
60
- subject.probed.should == 3
60
+ expect(subject.probed).to eq 3
61
61
  sleep(100.0 / 1000)
62
62
  2.times { subject.acquire }
63
- subject.probed.should == 5
63
+ expect(subject.probed).to eq 5
64
64
  end
65
65
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Sidekiq::LimitFetch do
3
+ RSpec.describe Sidekiq::LimitFetch do
4
4
  before :each do
5
5
  Sidekiq.redis do |it|
6
6
  it.del 'queue:queue1'
@@ -17,31 +17,31 @@ describe Sidekiq::LimitFetch do
17
17
 
18
18
  it 'should acquire lock on queue for execution' do
19
19
  work = subject.retrieve_work
20
- work.queue_name.should == 'queue1'
21
- work.message.should == 'task1'
20
+ expect(work.queue_name).to eq 'queue1'
21
+ expect(work.message).to eq 'task1'
22
22
 
23
- Sidekiq::Queue['queue1'].busy.should == 1
24
- Sidekiq::Queue['queue2'].busy.should == 0
23
+ expect(Sidekiq::Queue['queue1'].busy).to eq 1
24
+ expect(Sidekiq::Queue['queue2'].busy).to eq 0
25
25
 
26
- subject.retrieve_work.should_not be
26
+ expect(subject.retrieve_work).not_to be
27
27
  work.requeue
28
28
 
29
- Sidekiq::Queue['queue1'].busy.should == 0
30
- Sidekiq::Queue['queue2'].busy.should == 0
29
+ expect(Sidekiq::Queue['queue1'].busy).to eq 0
30
+ expect(Sidekiq::Queue['queue2'].busy).to eq 0
31
31
 
32
32
  work = subject.retrieve_work
33
- work.message.should == 'task1'
33
+ expect(work.message).to eq 'task1'
34
34
 
35
- Sidekiq::Queue['queue1'].busy.should == 1
36
- Sidekiq::Queue['queue2'].busy.should == 0
35
+ expect(Sidekiq::Queue['queue1'].busy).to eq 1
36
+ expect(Sidekiq::Queue['queue2'].busy).to eq 0
37
37
 
38
- subject.retrieve_work.should_not be
38
+ expect(subject.retrieve_work).not_to be
39
39
  work.acknowledge
40
40
 
41
- Sidekiq::Queue['queue1'].busy.should == 0
42
- Sidekiq::Queue['queue2'].busy.should == 0
41
+ expect(Sidekiq::Queue['queue1'].busy).to eq 0
42
+ expect(Sidekiq::Queue['queue2'].busy).to eq 0
43
43
 
44
44
  work = subject.retrieve_work
45
- work.message.should == 'task2'
45
+ expect(work.message).to eq 'task2'
46
46
  end
47
47
  end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,9 @@ Sidekiq.logger = nil
6
6
  Sidekiq.redis = { namespace: ENV['namespace'] }
7
7
 
8
8
  RSpec.configure do |config|
9
+ config.order = :random
10
+ config.disable_monkey_patching!
11
+ config.raise_errors_for_deprecations!
9
12
  config.before :each do
10
13
  Sidekiq::Queue.reset_instances!
11
14
  Sidekiq.redis do |it|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-limit_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-07 00:00:00.000000000 Z
11
+ date: 2015-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "<"
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '3.0'
39
+ version: 3.2.0
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "<"
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '3.0'
46
+ version: 3.2.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement