sidekiq-limit_fetch 2.4.0 → 2.4.1

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: af4e92376eea915d5ecb40d3d7183859062bf21c
4
- data.tar.gz: d596ab1071c952a68eb029a42c3cc4040be33f23
3
+ metadata.gz: 308521ae4ca41ec67f93b1e586c24d5b2704c6f2
4
+ data.tar.gz: 638d54dc481262e7bf13a128777cd22016106a3d
5
5
  SHA512:
6
- metadata.gz: 4994be60172a5e21930553db313433ef721c2082fcde29dab9a3b38f9241a0c3da94f216b1e36ebac34c880988100c37394d4b420dac651824d63dbde5ec42a3
7
- data.tar.gz: a46416a2481d50e3aa67ec45000ad66c4777f35a36e9d9d6ee1b57228eda0bc4599ec7da73594eda64095431c37da402b4384193b90577ef1ccd27bd3aa02231
6
+ metadata.gz: 6a584f739cc6c4c825a6c1da2e09aec8536ca866433605252220b503bc3fbabe75a35228053b4ba38656c7016b24aa466272c321cc0d1bd41eb04829c5e0f7f7
7
+ data.tar.gz: d62381535352afec36b7668792f0db79d069ec4b10ab0ede19dc7d6c69720a21612265338192ecd4f693e08a0bcc21d988b5e20bd47b025b38035a3a1fefbd0e
data/.travis.yml CHANGED
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - jruby-19mode
5
- - rbx-19mode
3
+ - 2.2.1
4
+ - jruby-head
5
+ - rbx-2
6
6
  services:
7
7
  - redis-server
8
8
  matrix:
9
9
  allow_failures:
10
- - rvm: rbx-19mode
10
+ - rvm: rbx-2
@@ -4,10 +4,10 @@ module Sidekiq
4
4
  attr_reader :rname
5
5
 
6
6
  def_delegators :lock,
7
- :limit, :limit=,
7
+ :limit, :limit=, :limit_changed?,
8
8
  :process_limit, :process_limit=,
9
9
  :acquire, :release,
10
- :pause, :pause_for_ms, :unpause,
10
+ :pause, :pause_for_ms, :unpause,
11
11
  :block, :unblock,
12
12
  :paused?, :blocking?,
13
13
  :unblocked, :block_except,
@@ -18,6 +18,8 @@ module Sidekiq::LimitFetch::Global
18
18
  end
19
19
 
20
20
  def limit=(value)
21
+ @limit_changed = true
22
+
21
23
  if value
22
24
  redis {|it| it.set "#{PREFIX}:limit:#@name", value }
23
25
  else
@@ -25,6 +27,10 @@ module Sidekiq::LimitFetch::Global
25
27
  end
26
28
  end
27
29
 
30
+ def limit_changed?
31
+ @limit_changed
32
+ end
33
+
28
34
  def process_limit
29
35
  value = redis {|it| it.get "#{PREFIX}:process_limit:#@name" }
30
36
  value.to_i if value
@@ -36,6 +36,15 @@ class Sidekiq::LimitFetch
36
36
  end
37
37
  end
38
38
 
39
+ def strict_order!
40
+ @queues.uniq!
41
+ def ordered_queues; @queues end
42
+ end
43
+
44
+ def weighted_order!
45
+ def ordered_queues; @queues.shuffle.uniq end
46
+ end
47
+
39
48
  private
40
49
 
41
50
  def selector
@@ -46,7 +55,7 @@ class Sidekiq::LimitFetch
46
55
  limits ||= {}
47
56
  each_queue do |queue|
48
57
  limit = limits[queue.name.to_s] || limits[queue.name.to_sym]
49
- queue.send "#{limit_type}=", limit
58
+ queue.send "#{limit_type}=", limit unless queue.limit_changed?
50
59
  end
51
60
  end
52
61
 
@@ -62,15 +71,6 @@ class Sidekiq::LimitFetch
62
71
  end
63
72
  end
64
73
 
65
- def strict_order!
66
- @queues.uniq!
67
- def ordered_queues; @queues end
68
- end
69
-
70
- def weighted_order!
71
- def ordered_queues; @queues.shuffle.uniq end
72
- end
73
-
74
74
  def save(queues)
75
75
  Thread.current[THREAD_KEY] = queues
76
76
  end
@@ -1,19 +1,24 @@
1
1
  module Sidekiq::LimitFetch::Redis
2
2
  extend self
3
3
 
4
- # prevent blocking of fetcher
5
- # more bullet-proof and faster (O_O)
6
- # than using Celluloid::IO
7
- #
8
- # https://github.com/brainopia/sidekiq-limit_fetch/issues/41
9
- # explanation of why Future#value is beneficial here
10
4
  def nonblocking_redis
11
5
  redis do |redis|
12
- begin
13
- Celluloid::Future.new { yield redis }.value
6
+ # Celluloid 0.16 broke this method
7
+ if Celluloid::VERSION.to_f >= 0.16
8
+ yield redis
9
+ else
10
+ # prevent blocking of fetcher
11
+ # more bullet-proof and faster (O_O)
12
+ # than using Celluloid::IO
13
+ #
14
+ # https://github.com/brainopia/sidekiq-limit_fetch/issues/41
15
+ # explanation of why Future#value is beneficial here
16
+ begin
17
+ Celluloid::Future.new { yield redis }.value
18
+ rescue Celluloid::Task::TerminatedError
19
+ end
14
20
  end
15
21
  end
16
- rescue Celluloid::Task::TerminatedError
17
22
  end
18
23
 
19
24
  def redis
@@ -12,4 +12,8 @@ module Sidekiq::LimitFetch::Singleton
12
12
  def instances
13
13
  @instances.values
14
14
  end
15
+
16
+ def reset_instances!
17
+ @instances = {}
18
+ end
15
19
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '2.4.0'
3
+ gem.version = '2.4.1'
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'
19
+ gem.add_development_dependency 'rspec', '< 3.0'
20
20
  gem.add_development_dependency 'rake'
21
21
  end
@@ -84,6 +84,13 @@ describe Sidekiq::Queue do
84
84
  queue.unblock
85
85
  queue.should_not be_blocking
86
86
  end
87
+
88
+ it 'should be marked as changed' do
89
+ queue = Sidekiq::Queue["uniq_#{name}"]
90
+ queue.should_not be_limit_changed
91
+ queue.limit = 3
92
+ queue.should be_limit_changed
93
+ end
87
94
  end
88
95
  end
89
96
  end
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@ Sidekiq.redis = { namespace: ENV['namespace'] }
7
7
 
8
8
  RSpec.configure do |config|
9
9
  config.before :each do
10
+ Sidekiq::Queue.reset_instances!
10
11
  Sidekiq.redis do |it|
11
12
  clean_redis = ->(queue) do
12
13
  it.pipelined do
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.0
4
+ version: 2.4.1
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-06 00:00:00.000000000 Z
11
+ date: 2015-03-07 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: '0'
39
+ version: '3.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: '0'
46
+ version: '3.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement