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 +4 -4
- data/.travis.yml +4 -4
- data/lib/sidekiq/extensions/queue.rb +2 -2
- data/lib/sidekiq/limit_fetch/global/semaphore.rb +6 -0
- data/lib/sidekiq/limit_fetch/queues.rb +10 -10
- data/lib/sidekiq/limit_fetch/redis.rb +14 -9
- data/lib/sidekiq/limit_fetch/singleton.rb +4 -0
- data/sidekiq-limit_fetch.gemspec +2 -2
- data/spec/sidekiq/extensions/queue_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308521ae4ca41ec67f93b1e586c24d5b2704c6f2
|
4
|
+
data.tar.gz: 638d54dc481262e7bf13a128777cd22016106a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a584f739cc6c4c825a6c1da2e09aec8536ca866433605252220b503bc3fbabe75a35228053b4ba38656c7016b24aa466272c321cc0d1bd41eb04829c5e0f7f7
|
7
|
+
data.tar.gz: d62381535352afec36b7668792f0db79d069ec4b10ab0ede19dc7d6c69720a21612265338192ecd4f693e08a0bcc21d988b5e20bd47b025b38035a3a1fefbd0e
|
data/.travis.yml
CHANGED
@@ -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,
|
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
|
-
|
13
|
-
|
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
|
data/sidekiq-limit_fetch.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'sidekiq-limit_fetch'
|
3
|
-
gem.version = '2.4.
|
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
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.
|
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-
|
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
|