resque-director 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,4 +7,6 @@ group :development do
7
7
  gem "bundler", "~> 1.0.0"
8
8
  gem "jeweler", "~> 1.6.4"
9
9
  gem "rcov", ">= 0"
10
+ gem "yajl-ruby", "~>0.8.2", :platforms => :mri
11
+ gem "json", "~>1.5.3", :platforms => :jruby
10
12
  end
data/README.rdoc CHANGED
@@ -41,9 +41,9 @@ For Example:
41
41
 
42
42
  === Start/Stop Options
43
43
 
44
- <b>start_override</b>:: This option takes a lambda closure that accepts the queue as an argument, the block you pass in will be responsible for starting a SINGLE worker allowing you to fully customize the starting of a worker. By default to start a worker the system command "QUEUE=queue_name rake resque:work &" is run, where queue_name is whatever queue the job is running.
44
+ <b>start_override</b>:: This option takes a lambda closure that accepts the queue as an argument, the block you pass in will be responsible for starting a SINGLE worker allowing you to fully customize the starting of a worker. If your block returns false then that signifies that a worker was not started and the last scaled time will not be set. By default to start a worker the system command "QUEUE=queue_name rake resque:work &" is run, where queue_name is whatever queue the job is running.
45
45
 
46
- <b>stop_override</b>:: This option takes a lambda closure that accepts the queue as an argument, the block you pass in will be responsible for stopping a SINGLE worker allowing you to fully customize the stopping of a worker. By default a to stop a worker the worker process on that host is sent a QUIT signal.
46
+ <b>stop_override</b>:: This option takes a lambda closure that accepts the queue as an argument, the block you pass in will be responsible for stopping a SINGLE worker allowing you to fully customize the stopping of a worker. If your block returns false then that signifies that a worker was not stopped and the last scaled time will not be set. By default a to stop a worker the worker process on that host is sent a QUIT signal.
47
47
 
48
48
  === Customized Starting/Stopping Workers Example
49
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.1
@@ -38,8 +38,9 @@ module Resque
38
38
 
39
39
  def scaling(number_of_workers=1)
40
40
  return unless time_to_scale? && number_of_workers > 0
41
- yield
42
- Resque.redis.set("last_scaled_#{Config.queue}", Time.now.utc.to_i)
41
+ unless yield == false
42
+ Resque.redis.set("last_scaled_#{Config.queue}", Time.now.utc.to_i)
43
+ end
43
44
  end
44
45
 
45
46
  private
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque-director}
8
- s.version = "2.1.0"
8
+ s.version = "2.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Nolan Frausto}]
12
- s.date = %q{2011-09-01}
12
+ s.date = %q{2011-09-02}
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
14
  s.email = %q{nrfrausto@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -54,12 +54,16 @@ Gem::Specification.new do |s|
54
54
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
55
55
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
56
56
  s.add_development_dependency(%q<rcov>, [">= 0"])
57
+ s.add_development_dependency(%q<yajl-ruby>, ["~> 0.8.2"])
58
+ s.add_development_dependency(%q<json>, ["~> 1.5.3"])
57
59
  else
58
60
  s.add_dependency(%q<resque>, ["~> 1.10"])
59
61
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
60
62
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
63
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
62
64
  s.add_dependency(%q<rcov>, [">= 0"])
65
+ s.add_dependency(%q<yajl-ruby>, ["~> 0.8.2"])
66
+ s.add_dependency(%q<json>, ["~> 1.5.3"])
63
67
  end
64
68
  else
65
69
  s.add_dependency(%q<resque>, ["~> 1.10"])
@@ -67,6 +71,8 @@ Gem::Specification.new do |s|
67
71
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
68
72
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
69
73
  s.add_dependency(%q<rcov>, [">= 0"])
74
+ s.add_dependency(%q<yajl-ruby>, ["~> 0.8.2"])
75
+ s.add_dependency(%q<json>, ["~> 1.5.3"])
70
76
  end
71
77
  end
72
78
 
@@ -48,6 +48,24 @@ describe Resque::Plugins::Director::Scaler do
48
48
  2.times { subject.scaling { @times_scaled += 1 } }
49
49
  @times_scaled.should == 2
50
50
  end
51
+
52
+ describe "last_scaled_test" do
53
+
54
+ before do
55
+ @now = Time.now
56
+ Time.stub(:now => @now)
57
+ end
58
+
59
+ it "should set the last scaled time" do
60
+ subject.scaling { true }
61
+ Resque.redis.get("last_scaled_test").to_i.should == @now.utc.to_i
62
+ end
63
+
64
+ it "should not set last scaled time if scaling block returns false" do
65
+ subject.scaling { false }
66
+ Resque.redis.get("last_scaled_test").should be_nil
67
+ end
68
+ end
51
69
  end
52
70
 
53
71
  describe "#scale_down_to_minimum" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-director
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 0
10
- version: 2.1.0
9
+ - 1
10
+ version: 2.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nolan Frausto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-01 00:00:00 Z
18
+ date: 2011-09-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -94,6 +94,38 @@ dependencies:
94
94
  name: rcov
95
95
  prerelease: false
96
96
  type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ hash: 59
104
+ segments:
105
+ - 0
106
+ - 8
107
+ - 2
108
+ version: 0.8.2
109
+ version_requirements: *id006
110
+ name: yajl-ruby
111
+ prerelease: false
112
+ type: :development
113
+ - !ruby/object:Gem::Dependency
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ~>
118
+ - !ruby/object:Gem::Version
119
+ hash: 5
120
+ segments:
121
+ - 1
122
+ - 5
123
+ - 3
124
+ version: 1.5.3
125
+ version_requirements: *id007
126
+ name: json
127
+ prerelease: false
128
+ type: :development
97
129
  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 "
98
130
  email: nrfrausto@gmail.com
99
131
  executables: []