resque-director 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,12 +1,13 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'resque', "~> 1.10"
4
+ gem "resque-remora", "~> 0.1.0"
4
5
 
5
6
  group :development do
6
- gem "rspec", "~> 2.3.0"
7
- gem "bundler", "~> 1.0.0"
7
+ gem "rspec", "~> 2.10.0"
8
+ gem "bundler", "~> 1.1.3"
8
9
  gem "jeweler", "~> 1.6.4"
9
- gem "rcov", ">= 0"
10
+ gem "simplecov", ">= 0"
10
11
  gem "yajl-ruby", "~>0.8.2", :platforms => :mri
11
12
  gem "json", "~>1.5.3", :platforms => :jruby
12
13
  end
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.2.3 (2011-09-09)
2
+
3
+ * Bugfix: remove race condition where it would not have the most up to date list of workers
4
+
1
5
  ## 2.2.2 (2011-09-09)
2
6
 
3
7
  * Bugfix: ignore wait_time when scaling to be within limits
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.2.4
@@ -1,11 +1,7 @@
1
1
  require 'resque'
2
+ require 'resque-remora'
2
3
 
3
4
  require 'resque/plugins/director'
4
5
  require 'resque/plugins/director/worker_tracker'
5
6
  require 'resque/plugins/director/config'
6
- require 'resque/plugins/director/scaler'
7
- require 'resque/plugins/director/push_pop'
8
-
9
- module Resque
10
- include Resque::Plugins::Director::PushPop
11
- end
7
+ require 'resque/plugins/director/scaler'
@@ -1,6 +1,18 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module Director
4
+ include Resque::Plugins::Remora
5
+
6
+ def attach_remora
7
+ {:created_at => Time.now.utc.to_i}
8
+ end
9
+
10
+ def process_remora(queue, job)
11
+ timestamp = job['created_at']
12
+ start_time = timestamp.nil? ? Time.now.utc : Time.at(timestamp.to_i).utc
13
+ after_pop_direct_workers(start_time)
14
+ end
15
+
4
16
  def direct(options={})
5
17
  Config.setup(options)
6
18
  Config.queue = options[:queue]
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{resque-director}
8
- s.version = "2.2.3"
7
+ s.name = "resque-director"
8
+ s.version = "2.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Nolan Frausto}]
12
- s.date = %q{2011-10-13}
13
- s.description = %q{resque plugin for automatically scaling workers based on the amount of time it takes a job to go through the queue and/or the length of the queue }
14
- s.email = %q{nrfrausto@gmail.com}
11
+ s.authors = ["Nolan Frausto"]
12
+ s.date = "2012-05-05"
13
+ s.description = "resque plugin for automatically scaling workers based on the amount of time it takes a job to go through the queue and/or the length of the queue "
14
+ s.email = "nrfrausto@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -26,51 +26,52 @@ Gem::Specification.new do |s|
26
26
  "lib/resque-director.rb",
27
27
  "lib/resque/plugins/director.rb",
28
28
  "lib/resque/plugins/director/config.rb",
29
- "lib/resque/plugins/director/push_pop.rb",
30
29
  "lib/resque/plugins/director/scaler.rb",
31
30
  "lib/resque/plugins/director/worker_tracker.rb",
32
31
  "resque-director.gemspec",
33
32
  "spec/redis-test.conf",
34
33
  "spec/resque/plugins/director/config_spec.rb",
35
- "spec/resque/plugins/director/push_pop_spec.rb",
36
34
  "spec/resque/plugins/director/scaler_spec.rb",
37
35
  "spec/resque/plugins/director/worker_tracker_spec.rb",
38
36
  "spec/resque/plugins/director_spec.rb",
39
37
  "spec/spec_helper.rb",
40
38
  "spec/support/jobs.rb"
41
39
  ]
42
- s.homepage = %q{http://github.com/frausto/resque-director}
43
- s.licenses = [%q{MIT}]
44
- s.require_paths = [%q{lib}]
45
- s.rubygems_version = %q{1.8.6}
46
- s.summary = %q{A resque plugin for automatically scaling workers}
40
+ s.homepage = "http://github.com/frausto/resque-director"
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = "1.8.24"
44
+ s.summary = "A resque plugin for automatically scaling workers"
47
45
 
48
46
  if s.respond_to? :specification_version then
49
47
  s.specification_version = 3
50
48
 
51
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
50
  s.add_runtime_dependency(%q<resque>, ["~> 1.10"])
53
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
54
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_runtime_dependency(%q<resque-remora>, ["~> 0.1.0"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.10.0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
55
54
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
56
- s.add_development_dependency(%q<rcov>, [">= 0"])
55
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
57
56
  s.add_development_dependency(%q<yajl-ruby>, ["~> 0.8.2"])
58
57
  s.add_development_dependency(%q<json>, ["~> 1.5.3"])
59
58
  else
60
59
  s.add_dependency(%q<resque>, ["~> 1.10"])
61
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
62
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<resque-remora>, ["~> 0.1.0"])
61
+ s.add_dependency(%q<rspec>, ["~> 2.10.0"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
63
63
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
64
- s.add_dependency(%q<rcov>, [">= 0"])
64
+ s.add_dependency(%q<simplecov>, [">= 0"])
65
65
  s.add_dependency(%q<yajl-ruby>, ["~> 0.8.2"])
66
66
  s.add_dependency(%q<json>, ["~> 1.5.3"])
67
67
  end
68
68
  else
69
69
  s.add_dependency(%q<resque>, ["~> 1.10"])
70
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
71
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
70
+ s.add_dependency(%q<resque-remora>, ["~> 0.1.0"])
71
+ s.add_dependency(%q<rspec>, ["~> 2.10.0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
72
73
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
73
- s.add_dependency(%q<rcov>, [">= 0"])
74
+ s.add_dependency(%q<simplecov>, [">= 0"])
74
75
  s.add_dependency(%q<yajl-ruby>, ["~> 0.8.2"])
75
76
  s.add_dependency(%q<json>, ["~> 1.5.3"])
76
77
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-director
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
4
  prerelease:
6
- segments:
7
- - 2
8
- - 2
9
- - 3
10
- version: 2.2.3
5
+ version: 2.2.4
11
6
  platform: ruby
12
7
  authors:
13
8
  - Nolan Frausto
@@ -15,117 +10,96 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-10-13 00:00:00 Z
13
+ date: 2012-05-05 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
- type: :runtime
16
+ name: resque
22
17
  requirement: &id001 !ruby/object:Gem::Requirement
23
18
  none: false
24
19
  requirements:
25
20
  - - ~>
26
21
  - !ruby/object:Gem::Version
27
- hash: 27
28
- segments:
29
- - 1
30
- - 10
31
22
  version: "1.10"
32
- version_requirements: *id001
33
- name: resque
23
+ type: :runtime
34
24
  prerelease: false
25
+ version_requirements: *id001
35
26
  - !ruby/object:Gem::Dependency
36
- type: :development
27
+ name: resque-remora
37
28
  requirement: &id002 !ruby/object:Gem::Requirement
38
29
  none: false
39
30
  requirements:
40
31
  - - ~>
41
32
  - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 2
45
- - 3
46
- - 0
47
- version: 2.3.0
48
- version_requirements: *id002
49
- name: rspec
33
+ version: 0.1.0
34
+ type: :runtime
50
35
  prerelease: false
36
+ version_requirements: *id002
51
37
  - !ruby/object:Gem::Dependency
52
- type: :development
38
+ name: rspec
53
39
  requirement: &id003 !ruby/object:Gem::Requirement
54
40
  none: false
55
41
  requirements:
56
42
  - - ~>
57
43
  - !ruby/object:Gem::Version
58
- hash: 23
59
- segments:
60
- - 1
61
- - 0
62
- - 0
63
- version: 1.0.0
64
- version_requirements: *id003
65
- name: bundler
44
+ version: 2.10.0
45
+ type: :development
66
46
  prerelease: false
47
+ version_requirements: *id003
67
48
  - !ruby/object:Gem::Dependency
68
- type: :development
49
+ name: bundler
69
50
  requirement: &id004 !ruby/object:Gem::Requirement
70
51
  none: false
71
52
  requirements:
72
53
  - - ~>
73
54
  - !ruby/object:Gem::Version
74
- hash: 7
75
- segments:
76
- - 1
77
- - 6
78
- - 4
79
- version: 1.6.4
55
+ version: 1.1.3
56
+ type: :development
57
+ prerelease: false
80
58
  version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
81
60
  name: jeweler
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.6.4
67
+ type: :development
82
68
  prerelease: false
69
+ version_requirements: *id005
83
70
  - !ruby/object:Gem::Dependency
84
- type: :development
85
- requirement: &id005 !ruby/object:Gem::Requirement
71
+ name: simplecov
72
+ requirement: &id006 !ruby/object:Gem::Requirement
86
73
  none: false
87
74
  requirements:
88
75
  - - ">="
89
76
  - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
77
  version: "0"
94
- version_requirements: *id005
95
- name: rcov
78
+ type: :development
96
79
  prerelease: false
80
+ version_requirements: *id006
97
81
  - !ruby/object:Gem::Dependency
98
- type: :development
99
- requirement: &id006 !ruby/object:Gem::Requirement
82
+ name: yajl-ruby
83
+ requirement: &id007 !ruby/object:Gem::Requirement
100
84
  none: false
101
85
  requirements:
102
86
  - - ~>
103
87
  - !ruby/object:Gem::Version
104
- hash: 59
105
- segments:
106
- - 0
107
- - 8
108
- - 2
109
88
  version: 0.8.2
110
- version_requirements: *id006
111
- name: yajl-ruby
89
+ type: :development
112
90
  prerelease: false
91
+ version_requirements: *id007
113
92
  - !ruby/object:Gem::Dependency
114
- type: :development
115
- requirement: &id007 !ruby/object:Gem::Requirement
93
+ name: json
94
+ requirement: &id008 !ruby/object:Gem::Requirement
116
95
  none: false
117
96
  requirements:
118
97
  - - ~>
119
98
  - !ruby/object:Gem::Version
120
- hash: 5
121
- segments:
122
- - 1
123
- - 5
124
- - 3
125
99
  version: 1.5.3
126
- version_requirements: *id007
127
- name: json
100
+ type: :development
128
101
  prerelease: false
102
+ version_requirements: *id008
129
103
  description: "resque plugin for automatically scaling workers based on the amount of time it takes a job to go through the queue and/or the length of the queue "
130
104
  email: nrfrausto@gmail.com
131
105
  executables: []
@@ -145,13 +119,11 @@ files:
145
119
  - lib/resque-director.rb
146
120
  - lib/resque/plugins/director.rb
147
121
  - lib/resque/plugins/director/config.rb
148
- - lib/resque/plugins/director/push_pop.rb
149
122
  - lib/resque/plugins/director/scaler.rb
150
123
  - lib/resque/plugins/director/worker_tracker.rb
151
124
  - resque-director.gemspec
152
125
  - spec/redis-test.conf
153
126
  - spec/resque/plugins/director/config_spec.rb
154
- - spec/resque/plugins/director/push_pop_spec.rb
155
127
  - spec/resque/plugins/director/scaler_spec.rb
156
128
  - spec/resque/plugins/director/worker_tracker_spec.rb
157
129
  - spec/resque/plugins/director_spec.rb
@@ -170,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
142
  requirements:
171
143
  - - ">="
172
144
  - !ruby/object:Gem::Version
173
- hash: 3
145
+ hash: -2861306429834219019
174
146
  segments:
175
147
  - 0
176
148
  version: "0"
@@ -179,14 +151,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
151
  requirements:
180
152
  - - ">="
181
153
  - !ruby/object:Gem::Version
182
- hash: 3
183
- segments:
184
- - 0
185
154
  version: "0"
186
155
  requirements: []
187
156
 
188
157
  rubyforge_project:
189
- rubygems_version: 1.8.6
158
+ rubygems_version: 1.8.24
190
159
  signing_key:
191
160
  specification_version: 3
192
161
  summary: A resque plugin for automatically scaling workers
@@ -1,37 +0,0 @@
1
- module Resque
2
- module Plugins
3
- module Director
4
- module PushPop
5
-
6
- def self.included(base)
7
- base.class_eval do
8
- alias_method :original_pop, :pop
9
- alias_method :original_push, :push
10
- extend ClassMethods
11
- end
12
- end
13
-
14
- module ClassMethods
15
- def push(queue, item)
16
- item[:created_at] = Time.now.utc.to_i if item.respond_to?(:[]=)
17
- original_push queue, item
18
- end
19
-
20
- def pop(queue)
21
- job = original_pop(queue)
22
- begin
23
- timestamp = job['created_at']
24
- start_time = timestamp.nil? ? Time.now.utc : Time.at(timestamp.to_i).utc
25
- job_class = constantize(job['class'])
26
- if job_class && job_class.respond_to?(:after_pop_direct_workers) && job_class.respond_to?(:direct)
27
- job_class.after_pop_direct_workers(start_time)
28
- end
29
- rescue
30
- end
31
- job
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Resque::Plugins::Director::PushPop do
4
- subject { Resque::Plugins::Director::PushPop }
5
-
6
- before do
7
- Resque::Plugins::Director::Config.queue = "test"
8
- @now = Time.now
9
- Time.stub(:now => @now)
10
- @timestamp = @now.utc.to_i
11
- end
12
-
13
- describe "#push" do
14
- it "should add the start timestamp to the end of the job" do
15
- Resque.enqueue(TestJob, "arg1")
16
- Resque.redis.lindex("queue:test",0).should =~ /^\{.*\"created_at\":#{@timestamp}/
17
- end
18
- end
19
-
20
- describe "#pop" do
21
- it "should direct workers using the timestamp" do
22
- Resque.enqueue(TestJob, "arg1")
23
- expected_time = Time.at(@timestamp).utc
24
- TestJob.should_receive(:after_pop_direct_workers).with(expected_time)
25
- Resque.pop("test").should == {"args"=>["arg1"], "class"=>"TestJob", "created_at"=>@timestamp}
26
- end
27
-
28
- it "should direct workers with current time if no start time" do
29
- Resque.should_receive(:original_pop).and_return({'args' => [], 'class' => 'TestJob'})
30
- TestJob.should_receive(:after_pop_direct_workers).with(@now)
31
- Resque.pop("test").should == {"args"=>[], "class"=>"TestJob"}
32
- end
33
-
34
- it "should not direct workers if the job is not directed" do
35
- Resque.enqueue(NonDirectedTestJob, "arg1")
36
- NonDirectedTestJob.should_not_receive(:after_pop_direct_workers)
37
- Resque.pop("non_directed").should include({"args"=>["arg1"], "class"=>"NonDirectedTestJob"})
38
- end
39
-
40
- it "should return the job properly if an exception is thrown in the direction logic" do
41
- Resque.enqueue(TestJob, "arg1")
42
- TestJob.should_receive(:after_pop_direct_workers).and_throw(:Exception)
43
- Resque.pop("test").should include({"args"=>["arg1"], "class"=>"TestJob"})
44
- end
45
- end
46
- end