resque-dynamic-queues 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -0
- data/CHANGELOG +21 -0
- data/LICENSE +20 -0
- data/README.md +32 -19
- data/lib/resque/plugins/dynamic_queues/queues.rb +9 -5
- data/lib/resque/plugins/dynamic_queues/version.rb +1 -1
- data/resque-dynamic-queues.gemspec +5 -0
- data/spec/queues_spec.rb +22 -0
- data/spec/redis-test.conf +1 -1
- data/spec/spec_helper.rb +22 -10
- metadata +33 -9
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
0.8.0
|
2
|
+
-----
|
3
|
+
|
4
|
+
Merge pull request #5 from kcrayon/master <016ae7c> [Matt Conway]
|
5
|
+
Add test for dynamic queue with negation <5f50574> [Chris Zutler]
|
6
|
+
Moving shuffling into branch. <a4360eb> [Chris Zutler]
|
7
|
+
Sort view of queues in web. <af53da5> [Chris Zutler]
|
8
|
+
Merge pull request #1 from snmaynard/patch-2 <92b437c> [kcrayon]
|
9
|
+
Shuffle the matching queues <f11585f> [Simon Maynard]
|
10
|
+
Slightly smarther dynamic queue negation. <184fa03> [Chris Zutler]
|
11
|
+
Add ability to blacklist dynamic queues. <d66b81b> [Chris Zutler]
|
12
|
+
Fix code blocks <75b782f> [Matt Conway]
|
13
|
+
Merge pull request #4 from billywatson/add_extra_tips_to_readme <25e6337> [Matt Conway]
|
14
|
+
add require note and document custom rake task ex. <78b6d6c> [William Watson]
|
15
|
+
only auto start/stop redis if not on CI <21ec8e0> [Matt Conway]
|
16
|
+
fix for rbx <94407b4> [Matt Conway]
|
17
|
+
fix for ruby 1.8 <2a50fbf> [Matt Conway]
|
18
|
+
enable travis ci <e8c0c16> [Matt Conway]
|
19
|
+
license date <bda1ae5> [Matt Conway]
|
20
|
+
license <498c222> [Matt Conway]
|
21
|
+
|
1
22
|
0.7.1
|
2
23
|
-----
|
3
24
|
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Matt Conway (matt@conwaysplace.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -4,46 +4,59 @@ Authored against Resque 1.15, so it at least works with that - try running the t
|
|
4
4
|
|
5
5
|
Usage:
|
6
6
|
|
7
|
+
If creating a gem of your own that uses resque-dynamic-queues, you may have to add an explicit require statement at the top of your Rakefile:
|
8
|
+
|
9
|
+
require 'resque-dynamic-queues'
|
10
|
+
|
7
11
|
Start your workers with a QUEUE that can contain '\*' for zero-or more of any character, '!' to exclude the following pattern, or @key to look up the patterns from redis. Some examples help:
|
8
12
|
|
9
|
-
QUEUE='foo' rake resque:work
|
13
|
+
QUEUE='foo' rake resque:work
|
14
|
+
|
15
|
+
Pulls jobs from the queue 'foo'
|
16
|
+
|
17
|
+
QUEUE='*' rake resque:work
|
10
18
|
|
11
|
-
|
19
|
+
Pulls jobs from any queue
|
12
20
|
|
13
|
-
QUEUE='
|
21
|
+
QUEUE='*foo' rake resque:work
|
14
22
|
|
15
|
-
|
23
|
+
Pulls jobs from queues that end in foo
|
16
24
|
|
17
|
-
QUEUE='
|
25
|
+
QUEUE='*foo*' rake resque:work
|
18
26
|
|
19
|
-
|
27
|
+
Pulls jobs from queues whose names contain foo
|
20
28
|
|
21
|
-
QUEUE='
|
29
|
+
QUEUE='*foo*,!foobar' rake resque:work
|
22
30
|
|
23
|
-
|
31
|
+
Pulls jobs from queues whose names contain foo except the foobar queue
|
24
32
|
|
25
|
-
QUEUE='
|
33
|
+
QUEUE='*foo*,!*bar' rake resque:work
|
26
34
|
|
27
|
-
|
35
|
+
Pulls jobs from queues whose names contain foo except queues whose names end in bar
|
28
36
|
|
29
|
-
QUEUE='
|
37
|
+
QUEUE='@key' rake resque:work
|
30
38
|
|
31
|
-
|
39
|
+
Pulls jobs from queue names stored in redis (use Resque.set\_dynamic\_queue("key", ["queuename1", "queuename2"]) to set them)
|
32
40
|
|
33
|
-
QUEUE='
|
41
|
+
QUEUE='*,!@key' rake resque:work
|
34
42
|
|
35
|
-
|
43
|
+
Pulls jobs from any queue execept ones stored in redis
|
36
44
|
|
37
|
-
QUEUE='@' rake resque:work
|
45
|
+
QUEUE='@' rake resque:work
|
38
46
|
|
39
|
-
|
47
|
+
Pulls jobs from queue names stored in redis using the hostname of the worker
|
40
48
|
|
41
|
-
Resque.
|
49
|
+
Resque.set_dynamic_queue("key", ["*foo*", "!*bar"])
|
50
|
+
QUEUE='@key' rake resque:work
|
42
51
|
|
43
|
-
|
52
|
+
Pulls jobs from queue names stored in redis, with wildcards/negations
|
44
53
|
|
45
|
-
|
54
|
+
task :custom_worker do
|
55
|
+
ENV['QUEUE'] = "*foo*,!*bar"
|
56
|
+
Rake::Task['resque:work'].invoke
|
57
|
+
end
|
46
58
|
|
59
|
+
From a custom rake script
|
47
60
|
|
48
61
|
|
49
62
|
There is also a tab in the resque-web UI that allows you to define the dynamic queues To activate it, you need to require 'resque-dynamic-queues-server' in whatever initializer you use to bring up resque-web.
|
@@ -24,17 +24,21 @@ module Resque
|
|
24
24
|
real_queues = Resque.queues
|
25
25
|
matched_queues = []
|
26
26
|
|
27
|
-
queue_names.
|
27
|
+
while q = queue_names.shift
|
28
28
|
q = q.to_s
|
29
29
|
|
30
|
-
if q =~
|
31
|
-
key = $
|
30
|
+
if q =~ /^(!)?@(.*)/
|
31
|
+
key = $2.strip
|
32
32
|
key = hostname if key.size == 0
|
33
|
-
|
33
|
+
|
34
|
+
add_queues = Resque.get_dynamic_queue(key)
|
35
|
+
add_queues.map! { |q| q.gsub!(/^!/, '') || q.gsub!(/^/, '!') } if $1
|
36
|
+
|
37
|
+
queue_names.concat(add_queues)
|
34
38
|
next
|
35
39
|
end
|
36
40
|
|
37
|
-
if q
|
41
|
+
if q =~ /^!/
|
38
42
|
negated = true
|
39
43
|
q = q[1..-1]
|
40
44
|
end
|
@@ -21,8 +21,13 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
23
|
s.add_dependency("resque", '~> 1.10')
|
24
|
+
|
25
|
+
s.add_development_dependency('rake')
|
24
26
|
s.add_development_dependency('rspec', '~> 2.5')
|
25
27
|
s.add_development_dependency('rack-test', '~> 0.5.4')
|
26
28
|
|
29
|
+
# Needed for testing newer resque on ruby 1.8.7
|
30
|
+
s.add_development_dependency('json')
|
31
|
+
|
27
32
|
end
|
28
33
|
|
data/spec/queues_spec.rb
CHANGED
@@ -144,6 +144,28 @@ describe "Dynamic Queues" do
|
|
144
144
|
worker.queues.should == ["bar", "foo"]
|
145
145
|
end
|
146
146
|
|
147
|
+
it "can blacklist dynamic queues" do
|
148
|
+
Resque.watch_queue("high_x")
|
149
|
+
Resque.watch_queue("foo")
|
150
|
+
Resque.watch_queue("high_y")
|
151
|
+
Resque.watch_queue("superhigh_z")
|
152
|
+
|
153
|
+
Resque.set_dynamic_queue("mykey", ["foo"])
|
154
|
+
worker = Resque::Worker.new("*", "!@mykey")
|
155
|
+
worker.queues.should == ["high_x", "high_y", "superhigh_z"]
|
156
|
+
end
|
157
|
+
|
158
|
+
it "can blacklist dynamic queues with negation" do
|
159
|
+
Resque.watch_queue("high_x")
|
160
|
+
Resque.watch_queue("foo")
|
161
|
+
Resque.watch_queue("high_y")
|
162
|
+
Resque.watch_queue("superhigh_z")
|
163
|
+
|
164
|
+
Resque.set_dynamic_queue("mykey", ["!foo", "high_x"])
|
165
|
+
worker = Resque::Worker.new("!@mykey")
|
166
|
+
worker.queues.should == ["foo"]
|
167
|
+
end
|
168
|
+
|
147
169
|
it "will not bloat the workers queue" do
|
148
170
|
Resque.watch_queue("high_x")
|
149
171
|
worker = Resque::Worker.new("@mykey")
|
data/spec/redis-test.conf
CHANGED
@@ -21,7 +21,7 @@ daemonize yes
|
|
21
21
|
pidfile ./redis.pid
|
22
22
|
|
23
23
|
# Accept connections on the specified port, default is 6379
|
24
|
-
port
|
24
|
+
port 6379
|
25
25
|
|
26
26
|
# If you want you can bind a single interface, if the bind option is not
|
27
27
|
# specified all the interfaces will listen for incoming connections.
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,29 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'resque-dynamic-queues'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
# No need to start redis when running in Travis
|
5
|
+
unless ENV['CI']
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
begin
|
8
|
+
Resque.queues
|
9
|
+
rescue Errno::ECONNREFUSED
|
10
|
+
spec_dir = File.dirname(File.expand_path(__FILE__))
|
11
|
+
REDIS_CMD = "redis-server #{spec_dir}/redis-test.conf"
|
12
|
+
|
13
|
+
puts "Starting redis for testing at localhost..."
|
14
|
+
puts `cd #{spec_dir}; #{REDIS_CMD}`
|
15
|
+
|
16
|
+
# Schedule the redis server for shutdown when tests are all finished.
|
17
|
+
at_exit do
|
18
|
+
puts 'Stopping redis'
|
19
|
+
pid = File.read("#{spec_dir}/redis.pid").to_i rescue nil
|
20
|
+
system ("kill -9 #{pid}") if pid.to_i != 0
|
21
|
+
File.delete("#{spec_dir}/redis.pid") rescue nil
|
22
|
+
File.delete("#{spec_dir}/redis-server.log") rescue nil
|
23
|
+
File.delete("#{spec_dir}/dump.rdb") rescue nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
end
|
16
28
|
|
17
29
|
class SomeJob
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-dynamic-queues
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: resque
|
16
|
-
requirement: &
|
16
|
+
requirement: &70360381659380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,21 @@ dependencies:
|
|
21
21
|
version: '1.10'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70360381659380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70360381658480 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70360381658480
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rspec
|
27
|
-
requirement: &
|
38
|
+
requirement: &70360381656740 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: '2.5'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70360381656740
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rack-test
|
38
|
-
requirement: &
|
49
|
+
requirement: &70360381655900 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
@@ -43,7 +54,18 @@ dependencies:
|
|
43
54
|
version: 0.5.4
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70360381655900
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: json
|
60
|
+
requirement: &70360381655180 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70360381655180
|
47
69
|
description: A resque plugin for specifying the queues a worker pulls from with wildcards,
|
48
70
|
negations, or dynamic look up from redis
|
49
71
|
email:
|
@@ -53,8 +75,10 @@ extensions: []
|
|
53
75
|
extra_rdoc_files: []
|
54
76
|
files:
|
55
77
|
- .gitignore
|
78
|
+
- .travis.yml
|
56
79
|
- CHANGELOG
|
57
80
|
- Gemfile
|
81
|
+
- LICENSE
|
58
82
|
- README.md
|
59
83
|
- Rakefile
|
60
84
|
- config.ru
|
@@ -91,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
115
|
version: '0'
|
92
116
|
requirements: []
|
93
117
|
rubyforge_project: resque-dynamic-queues
|
94
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.15
|
95
119
|
signing_key:
|
96
120
|
specification_version: 3
|
97
121
|
summary: A resque plugin for specifying the queues a worker pulls from with wildcards,
|