sidekiq-limit_fetch 1.4 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45106fd76c4d8e0bb1621e904f0826b08450ac42
4
- data.tar.gz: 776c116e27e48b3262a7a201f9fd7e3843c800e0
3
+ metadata.gz: c530f12f2c18dba1c729e6271112081154a78b7f
4
+ data.tar.gz: 0d9a6695cad3ec9965a2629ef8e8b83b171bcb8d
5
5
  SHA512:
6
- metadata.gz: 19b51939f0560f367ee1ccb167c0b251f3dc6af1abd0cf4cac9f76eb760c098c8a479e99ddc1cdb3d068f4c3267ccdad49174505cb2e49fb82b59ede7a0eba36
7
- data.tar.gz: f975a401b537405c83c597490b42cf37d46f9ee5c433744accb5dd28ea6b27d5c377f85fe6518117118eaf93adfe9f318713faae16c56117ada55be3f5cfede2
6
+ metadata.gz: 30851e2e580ae34f6e2a67d7fe6a44397e723a9811377d0afb4defc2a04ea821a5b498b16df70666558f04070923e1549f0c4e4a4633110a0f2d3b13b67c9dee
7
+ data.tar.gz: f445df4cec59bf1773f9947eb3fd76b5e19eeacba7e73a6136bcd99828bd94dd2fe3c2ac48a60f2e3d6deb371add6251b55273e5a49883790e1e840581a2bb5e
data/README.md CHANGED
@@ -58,23 +58,6 @@ will be preserved.
58
58
  Sidekiq::Queue['name'].unpause # allows workers to use the queue
59
59
  ```
60
60
 
61
- ### Multiple processes
62
-
63
- Limits are applied per process. In case you have several worker
64
- processes and want to have global locks between them, you'll need to
65
- enable global mode by setting global option, eg:
66
-
67
- ```yaml
68
- :global: true
69
- ```
70
-
71
- or
72
-
73
- ```ruby
74
- Sidekiq.options[:global] = true
75
- ```
76
-
77
-
78
61
  ### Blocking queue mode
79
62
 
80
63
  If you use strict queue ordering (it will be used if you don't specify queue weights)
@@ -16,7 +16,7 @@ module Sidekiq
16
16
  end
17
17
 
18
18
  def mode
19
- Sidekiq.options[:global] ? LimitFetch::Global : LimitFetch::Local
19
+ Sidekiq.options[:local] ? LimitFetch::Local : LimitFetch::Global
20
20
  end
21
21
  end
22
22
  end
@@ -7,7 +7,7 @@ class Sidekiq::LimitFetch
7
7
  @queues = options[:queues]
8
8
  options[:strict] ? strict_order! : weighted_order!
9
9
 
10
- set_selector options[:global]
10
+ set_selector options[:local]
11
11
  set_limits options[:limits]
12
12
  set_blocks options[:blocking]
13
13
  end
@@ -26,8 +26,8 @@ class Sidekiq::LimitFetch
26
26
 
27
27
  private
28
28
 
29
- def set_selector(global)
30
- @selector = global ? Global::Selector : Local::Selector
29
+ def set_selector(local)
30
+ @selector = local ? Local::Selector : Global::Selector
31
31
  end
32
32
 
33
33
  def set_limits(limits)
@@ -19,7 +19,7 @@ class Sidekiq::LimitFetch
19
19
  end
20
20
 
21
21
  def initialize(options)
22
- Global::Monitor.start! if options[:global]
22
+ Global::Monitor.start! unless options[:local]
23
23
  @queues = Queues.new options
24
24
  end
25
25
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '1.4'
3
+ gem.version = '1.5'
4
4
  gem.authors = 'brainopia'
5
5
  gem.email = 'brainopia@evilmartians.com'
6
6
  gem.summary = 'Sidekiq strategy to support queue limits'
@@ -88,12 +88,12 @@ describe Sidekiq::Queue do
88
88
  end
89
89
 
90
90
  context 'global' do
91
- before(:all) { Sidekiq.options[:global] = true }
91
+ before(:all) { Sidekiq.options[:local] = false }
92
92
  it_behaves_like :lock
93
93
  end
94
94
 
95
95
  context 'local' do
96
- before(:all) { Sidekiq.options[:global] = false }
96
+ before(:all) { Sidekiq.options[:local] = true }
97
97
  it_behaves_like :lock
98
98
  end
99
99
  end
@@ -1,13 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Sidekiq::LimitFetch::Global::Monitor do
4
- let(:global) { true }
5
4
  let(:monitor) { described_class.start! ttl, timeout }
6
5
  let(:ttl) { 1 }
7
6
  let(:queue) { Sidekiq::Queue[name] }
8
7
  let(:name) { 'default' }
9
8
 
10
9
  before :each do
10
+ # namespaces = [
11
+ # described_class::PROCESSOR_NAMESPACE,
12
+ # described_class::HEARTBEAT_NAMESPACE
13
+ # ]
14
+
15
+ # Sidekiq.redis do |it|
16
+ # namespaces.flat_map {|namespace|
17
+ # it.keys(namespace + '*')
18
+ # }.each {|key| it.del key }
19
+ # end
20
+
11
21
  monitor
12
22
  end
13
23
 
@@ -3,17 +3,17 @@ require 'spec_helper'
3
3
  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(:global) { false }
10
- let(:blocking) { nil }
6
+ let(:queues) { %w[queue1 queue2] }
7
+ let(:limits) {{ 'queue1' => 3 }}
8
+ let(:strict) { true }
9
+ let(:local) {}
10
+ let(:blocking) {}
11
11
 
12
12
  let(:options) do
13
- { queues: queues,
14
- limits: limits,
15
- strict: strict,
16
- global: global,
13
+ { queues: queues,
14
+ limits: limits,
15
+ strict: strict,
16
+ local: local,
17
17
  blocking: blocking }
18
18
  end
19
19
 
@@ -83,20 +83,20 @@ describe Sidekiq::LimitFetch::Queues do
83
83
  end
84
84
  end
85
85
 
86
- context 'without global flag' do
86
+ context 'without local flag' do
87
87
  it_should_behave_like :selector
88
88
 
89
- it 'without global flag should be local' do
90
- subject.selector.should == Sidekiq::LimitFetch::Local::Selector
89
+ it 'without local flag should be global' do
90
+ subject.selector.should == Sidekiq::LimitFetch::Global::Selector
91
91
  end
92
92
  end
93
93
 
94
- context 'with global flag' do
95
- let(:global) { true }
94
+ context 'with local flag' do
95
+ let(:local) { true }
96
96
  it_should_behave_like :selector
97
97
 
98
- it 'should use global selector' do
99
- subject.selector.should == Sidekiq::LimitFetch::Global::Selector
98
+ it 'should use local selector' do
99
+ subject.selector.should == Sidekiq::LimitFetch::Local::Selector
100
100
  end
101
101
  end
102
102
 
@@ -11,7 +11,7 @@ describe Sidekiq::LimitFetch do
11
11
  end
12
12
 
13
13
  subject { described_class.new options }
14
- let(:options) {{ queues: queues, limits: limits, global: global }}
14
+ let(:options) {{ queues: queues, limits: limits, local: local }}
15
15
  let(:queues) { %w(queue1 queue1 queue2 queue2) }
16
16
  let(:limits) {{ 'queue1' => 1, 'queue2' => 2 }}
17
17
 
@@ -36,12 +36,12 @@ describe Sidekiq::LimitFetch do
36
36
  end
37
37
 
38
38
  context 'global' do
39
- let(:global) { true }
39
+ let(:local) { false }
40
40
  it_behaves_like :strategy
41
41
  end
42
42
 
43
43
  context 'local' do
44
- let(:global) { false }
44
+ let(:local) { true }
45
45
  it_behaves_like :strategy
46
46
  end
47
47
  end
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,8 @@ require 'sidekiq/limit_fetch'
3
3
  RSpec.configure do |config|
4
4
  config.before :each do
5
5
  Sidekiq::Queue.instance_variable_set :@instances, {}
6
- Sidekiq.options[:global] = defined?(global) ? global : nil
7
-
6
+ Sidekiq.options[:local] = defined?(local) ? local : nil
7
+
8
8
  Sidekiq.redis do |it|
9
9
  clean_redis = ->(queue) do
10
10
  it.del "limit_fetch:limit:#{queue}"
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: '1.4'
4
+ version: '1.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-26 00:00:00.000000000 Z
11
+ date: 2013-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq