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.
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - jruby-18mode # JRuby in 1.8 mode
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-18mode
9
+ # - rbx-19mode
10
+ script: bundle exec rspec spec
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 0.6.0
2
+ -----
3
+
4
+ Allow multiple patterns per priority bucket, along with negation patterns
5
+
1
6
  0.5.3
2
7
  -----
3
8
 
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.
@@ -37,7 +37,7 @@ module Resque
37
37
  patterns.each do |pattern|
38
38
  pattern = pattern.strip
39
39
 
40
- if pattern[0] == '!'
40
+ if pattern =~ /^!/
41
41
  negated = true
42
42
  pattern = pattern[1..-1]
43
43
  end
@@ -18,7 +18,7 @@ module Resque
18
18
  app.post "/queuepriority" do
19
19
  priorities = params['priorities']
20
20
  Resque.priority_buckets = priorities
21
- redirect url(:queuepriority)
21
+ redirect "/queuepriority"
22
22
  end
23
23
 
24
24
  app.helpers do
@@ -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="<%= url(:queuepriority) %>" method="POST" style="float:none; margin-top:10px">
6
+ <form action="/queuepriority" method="POST" style="float:none; margin-top:10px">
7
7
 
8
8
  <table class="priorities">
9
9
  <tr>
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module QueuePriority
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
6
6
  end
7
7
  end
@@ -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
 
@@ -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 == ["foo", "high_x", "high_y", "superhigh_z"]
90
- worker.queues.sort.should == ["foo", "high_x", "high_y", "superhigh_z"]
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
@@ -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 9736
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.
@@ -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="http:\/\/example.org\/queuepriority"/
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
- post "/queuepriority", {'priorities' => [{"pattern" => "foo"},
106
- {"pattern" => "default"},
107
- {"pattern" => "bar", "fairly" => "true"}]}
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/
@@ -1,17 +1,29 @@
1
1
  require 'rspec'
2
2
  require 'resque-queue-priority'
3
3
 
4
- spec_dir = File.dirname(File.expand_path(__FILE__))
5
- REDIS_CMD = "redis-server #{spec_dir}/redis-test.conf"
4
+ # No need to start redis when running in Travis
5
+ unless ENV['CI']
6
6
 
7
- puts "Starting redis for testing at localhost:9736..."
8
- puts `cd #{spec_dir}; #{REDIS_CMD}`
9
- Resque.redis = 'localhost:9736'
10
-
11
- # Schedule the redis server for shutdown when tests are all finished.
12
- at_exit do
13
- pid = File.read("#{spec_dir}/redis.pid").to_i rescue nil
14
- system ("kill #{pid}") if pid != 0
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.0
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: 2011-12-19 00:00:00.000000000Z
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: &2154438400 !ruby/object:Gem::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: *2154438400
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: &2154437980 !ruby/object:Gem::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: *2154437980
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: &2154437440 !ruby/object:Gem::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: *2154437440
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: &2154436940 !ruby/object:Gem::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: *2154436940
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.10
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