resque-queue-priority 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -0
- data/CHANGELOG +5 -0
- data/LICENSE +20 -0
- data/README.md +2 -0
- data/lib/resque/plugins/queue_priority/priority.rb +1 -1
- data/lib/resque/plugins/queue_priority/server.rb +1 -1
- data/lib/resque/plugins/queue_priority/server/views/priorities.erb +1 -1
- data/lib/resque/plugins/queue_priority/version.rb +1 -1
- data/resque-queue-priority.gemspec +6 -0
- data/spec/priority_spec.rb +4 -2
- data/spec/redis-test.conf +1 -1
- data/spec/server_spec.rb +8 -4
- data/spec/spec_helper.rb +22 -10
- metadata +65 -11
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
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
@@ -2,6 +2,8 @@ A resque plugin for specifying the order a worker will prioritize queues in.
|
|
2
2
|
|
3
3
|
Authored against Resque 1.17.1, so it at least works with that - try running the tests if you use a different version of resque
|
4
4
|
|
5
|
+
[![Build Status](https://secure.travis-ci.org/wr0ngway/resque-queue-priority.png)](http://travis-ci.org/wr0ngway/resque-queue-priority)
|
6
|
+
|
5
7
|
Usage:
|
6
8
|
|
7
9
|
Start your workers with a QUEUE that contains many queue names - this plugin is most useful when using '\*' or a plugin like resque-dynamic-queues.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
The list below orders queue name patterns by the priority you wish them to be executed in. The "Fairly" option allows you to indicate you want the queues within that pattern space be selected in a fair (random) manner, i.e. like resque-fairly. The 'default' pattern must always exist, and matches against all queues that aren't in any of the other patterns.
|
4
4
|
</p>
|
5
5
|
|
6
|
-
<form action="
|
6
|
+
<form action="/queuepriority" method="POST" style="float:none; margin-top:10px">
|
7
7
|
|
8
8
|
<table class="priorities">
|
9
9
|
<tr>
|
@@ -21,9 +21,15 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
23
|
s.add_dependency("resque", '~> 1.10')
|
24
|
+
|
24
25
|
s.add_development_dependency('rake')
|
25
26
|
s.add_development_dependency('rspec', '~> 2.5')
|
26
27
|
s.add_development_dependency('rack-test', '~> 0.5.4')
|
27
28
|
|
29
|
+
# Needed for testing newer resque on ruby 1.8.7
|
30
|
+
s.add_development_dependency('json')
|
31
|
+
# Needed for correct ordering when passing hash params to rack-test
|
32
|
+
s.add_development_dependency('orderedhash')
|
33
|
+
|
28
34
|
end
|
29
35
|
|
data/spec/priority_spec.rb
CHANGED
@@ -84,10 +84,12 @@ describe "Queue Priority" do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should pick up all queues fairly" do
|
87
|
+
# do a bunch to reduce likyhood of random match causing test failure
|
88
|
+
50.times {|i| Resque.watch_queue("auto_#{i}") }
|
87
89
|
Resque.priority_buckets = [{'pattern' => 'default', 'fairly' => true}]
|
88
90
|
worker = Resque::Worker.new("*")
|
89
|
-
worker.queues.should_not ==
|
90
|
-
worker.queues.sort.should ==
|
91
|
+
worker.queues.should_not == Resque.queues.sort
|
92
|
+
worker.queues.sort.should == Resque.queues.sort
|
91
93
|
end
|
92
94
|
|
93
95
|
it "should prioritize simple pattern" do
|
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/server_spec.rb
CHANGED
@@ -5,6 +5,7 @@ require 'rack'
|
|
5
5
|
require 'rack/test'
|
6
6
|
require 'resque/server'
|
7
7
|
require 'resque-queue-priority-server'
|
8
|
+
require 'orderedhash'
|
8
9
|
|
9
10
|
Sinatra::Base.set :environment, :test
|
10
11
|
# ::Test::Unit::TestCase.send :include, Rack::Test::Methods
|
@@ -96,15 +97,18 @@ describe "Queue Priority pages" do
|
|
96
97
|
it "should have form to edit queues" do
|
97
98
|
get "/queuepriority"
|
98
99
|
|
99
|
-
last_response.body.should match /<form action="
|
100
|
+
last_response.body.should match /<form action="\/queuepriority"/
|
100
101
|
end
|
101
102
|
|
102
103
|
it "should update queues" do
|
103
104
|
Resque.priority_buckets.should == [{'pattern' => 'default'}]
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
106
|
+
params = {'priorities' => [
|
107
|
+
OrderedHash["pattern", "foo"],
|
108
|
+
OrderedHash["pattern", "default"],
|
109
|
+
OrderedHash["pattern", "bar", "fairly", "true"]
|
110
|
+
]}
|
111
|
+
post "/queuepriority", params
|
108
112
|
|
109
113
|
last_response.should be_redirect
|
110
114
|
last_response['Location'].should match /queuepriority/
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,29 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'resque-queue-priority'
|
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-queue-priority
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
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-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: resque
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '1.10'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.10'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rake
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '2.5'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.5'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rack-test
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,7 +69,44 @@ dependencies:
|
|
54
69
|
version: 0.5.4
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.5.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: json
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: orderedhash
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
58
110
|
description: A resque plugin for specifying the priority between queues that workers
|
59
111
|
use to determine what to work on next
|
60
112
|
email:
|
@@ -64,8 +116,10 @@ extensions: []
|
|
64
116
|
extra_rdoc_files: []
|
65
117
|
files:
|
66
118
|
- .gitignore
|
119
|
+
- .travis.yml
|
67
120
|
- CHANGELOG
|
68
121
|
- Gemfile
|
122
|
+
- LICENSE
|
69
123
|
- README.md
|
70
124
|
- Rakefile
|
71
125
|
- config.ru
|
@@ -101,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
155
|
version: '0'
|
102
156
|
requirements: []
|
103
157
|
rubyforge_project: resque-queue-priority
|
104
|
-
rubygems_version: 1.8.
|
158
|
+
rubygems_version: 1.8.21
|
105
159
|
signing_key:
|
106
160
|
specification_version: 3
|
107
161
|
summary: A resque plugin for specifying the priority between queues that workers use
|