heroku-resque-workers-scaler 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rvmrc +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +97 -86
- data/{README.rdoc → README.md} +13 -2
- data/heroku-resque-workers-scaler.gemspec +2 -1
- data/lib/heroku-resque-workers-scaler/config.rb +12 -2
- data/lib/heroku-resque-workers-scaler/scaler.rb +26 -13
- data/lib/heroku-resque-workers-scaler/version.rb +1 -1
- data/spec/heroku-resque-workers-scaler/config_spec.rb +22 -2
- data/spec/heroku-resque-workers-scaler/scaler_spec.rb +55 -39
- metadata +17 -5
- data/heroku-resque-workers-scaler-0.1.5.gem +0 -0
- data/heroku-resque-workers-scaler-0.1.6.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13c53ba1d25943cf147a88cad016bd1f27533322
|
|
4
|
+
data.tar.gz: 1614140657d92c11e5a0fc4b65fb3d2c27013cfd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d710e9001c4caa3e3837433339a6660a9a1c2e285768701d40f655d8eb160a68a8f09edbce58f816adf1f38ccae4579f8ca5945c7d37e8feef823337a236100
|
|
7
|
+
data.tar.gz: e801d73f45408acfb158e5a7ff4871a73338881d70a28e06aed35c436cff72ef4c0601bf2d45cfa4679067cf331d6044f23c0692ee100a0cb8d8958316eb3321
|
data/.rvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
rvm use ruby-1.
|
|
1
|
+
rvm use ruby-2.1.1@scaler --create
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,88 +1,90 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
heroku-resque-workers-scaler (0.1.
|
|
5
|
-
|
|
4
|
+
heroku-resque-workers-scaler (0.1.9)
|
|
5
|
+
platform-api
|
|
6
6
|
resque
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actionmailer (
|
|
12
|
-
actionpack (=
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
actionmailer (4.1.1)
|
|
12
|
+
actionpack (= 4.1.1)
|
|
13
|
+
actionview (= 4.1.1)
|
|
14
|
+
mail (~> 2.5.4)
|
|
15
|
+
actionpack (4.1.1)
|
|
16
|
+
actionview (= 4.1.1)
|
|
17
|
+
activesupport (= 4.1.1)
|
|
18
|
+
rack (~> 1.5.2)
|
|
19
|
+
rack-test (~> 0.6.2)
|
|
20
|
+
actionview (4.1.1)
|
|
21
|
+
activesupport (= 4.1.1)
|
|
22
|
+
builder (~> 3.1)
|
|
18
23
|
erubis (~> 2.7.0)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
tzinfo (~>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
addressable (2.3.2)
|
|
39
|
-
arel (3.0.2)
|
|
40
|
-
builder (3.0.4)
|
|
41
|
-
crack (0.3.1)
|
|
42
|
-
diff-lcs (1.1.3)
|
|
24
|
+
activemodel (4.1.1)
|
|
25
|
+
activesupport (= 4.1.1)
|
|
26
|
+
builder (~> 3.1)
|
|
27
|
+
activerecord (4.1.1)
|
|
28
|
+
activemodel (= 4.1.1)
|
|
29
|
+
activesupport (= 4.1.1)
|
|
30
|
+
arel (~> 5.0.0)
|
|
31
|
+
activesupport (4.1.1)
|
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
33
|
+
json (~> 1.7, >= 1.7.7)
|
|
34
|
+
minitest (~> 5.1)
|
|
35
|
+
thread_safe (~> 0.1)
|
|
36
|
+
tzinfo (~> 1.1)
|
|
37
|
+
addressable (2.3.6)
|
|
38
|
+
arel (5.0.1.20140414130214)
|
|
39
|
+
builder (3.2.2)
|
|
40
|
+
crack (0.4.2)
|
|
41
|
+
safe_yaml (~> 1.0.0)
|
|
42
|
+
diff-lcs (1.2.5)
|
|
43
43
|
erubis (2.7.0)
|
|
44
|
-
excon (0.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
excon (0.39.5)
|
|
45
|
+
heroics (0.0.12)
|
|
46
|
+
erubis (~> 2.7.0)
|
|
47
|
+
excon
|
|
48
|
+
moneta
|
|
49
|
+
multi_json (>= 1.9.2)
|
|
50
|
+
netrc
|
|
51
|
+
hike (1.2.3)
|
|
52
|
+
i18n (0.6.9)
|
|
53
|
+
json (1.8.1)
|
|
54
|
+
mail (2.5.4)
|
|
53
55
|
mime-types (~> 1.16)
|
|
54
56
|
treetop (~> 1.4.8)
|
|
55
|
-
mime-types (1.
|
|
57
|
+
mime-types (1.25.1)
|
|
58
|
+
minitest (5.3.4)
|
|
59
|
+
moneta (0.8.0)
|
|
56
60
|
mono_logger (1.1.0)
|
|
57
|
-
multi_json (1.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
multi_json (1.10.0)
|
|
62
|
+
netrc (0.7.7)
|
|
63
|
+
platform-api (0.2.0)
|
|
64
|
+
heroics (~> 0.0.10)
|
|
65
|
+
polyglot (0.3.4)
|
|
66
|
+
psych (2.0.5)
|
|
67
|
+
rack (1.5.2)
|
|
62
68
|
rack-protection (1.5.3)
|
|
63
69
|
rack
|
|
64
|
-
rack-ssl (1.3.2)
|
|
65
|
-
rack
|
|
66
70
|
rack-test (0.6.2)
|
|
67
71
|
rack (>= 1.0)
|
|
68
|
-
rails (
|
|
69
|
-
actionmailer (=
|
|
70
|
-
actionpack (=
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
rails (4.1.1)
|
|
73
|
+
actionmailer (= 4.1.1)
|
|
74
|
+
actionpack (= 4.1.1)
|
|
75
|
+
actionview (= 4.1.1)
|
|
76
|
+
activemodel (= 4.1.1)
|
|
77
|
+
activerecord (= 4.1.1)
|
|
78
|
+
activesupport (= 4.1.1)
|
|
79
|
+
bundler (>= 1.3.0, < 2.0)
|
|
80
|
+
railties (= 4.1.1)
|
|
81
|
+
sprockets-rails (~> 2.0)
|
|
82
|
+
railties (4.1.1)
|
|
83
|
+
actionpack (= 4.1.1)
|
|
84
|
+
activesupport (= 4.1.1)
|
|
80
85
|
rake (>= 0.8.7)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
rake (0.8.7)
|
|
84
|
-
rdoc (3.12)
|
|
85
|
-
json (~> 1.4)
|
|
86
|
+
thor (>= 0.18.1, < 2.0)
|
|
87
|
+
rake (10.3.2)
|
|
86
88
|
redis (3.1.0)
|
|
87
89
|
redis-namespace (1.5.1)
|
|
88
90
|
redis (~> 3.0, >= 3.0.4)
|
|
@@ -92,39 +94,48 @@ GEM
|
|
|
92
94
|
redis-namespace (~> 1.3)
|
|
93
95
|
sinatra (>= 0.9.2)
|
|
94
96
|
vegas (~> 0.1.2)
|
|
95
|
-
rspec (2.
|
|
96
|
-
rspec-core (~> 2.
|
|
97
|
-
rspec-expectations (~> 2.
|
|
98
|
-
rspec-mocks (~> 2.
|
|
99
|
-
rspec-core (2.
|
|
100
|
-
rspec-expectations (2.
|
|
101
|
-
diff-lcs (
|
|
102
|
-
rspec-mocks (2.
|
|
103
|
-
|
|
97
|
+
rspec (2.14.1)
|
|
98
|
+
rspec-core (~> 2.14.0)
|
|
99
|
+
rspec-expectations (~> 2.14.0)
|
|
100
|
+
rspec-mocks (~> 2.14.0)
|
|
101
|
+
rspec-core (2.14.8)
|
|
102
|
+
rspec-expectations (2.14.5)
|
|
103
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
104
|
+
rspec-mocks (2.14.6)
|
|
105
|
+
safe_yaml (1.0.3)
|
|
106
|
+
sinatra (1.4.5)
|
|
104
107
|
rack (~> 1.4)
|
|
105
|
-
rack-protection (~> 1.
|
|
106
|
-
tilt (~> 1.3, >= 1.3.
|
|
107
|
-
sprockets (2.1
|
|
108
|
+
rack-protection (~> 1.4)
|
|
109
|
+
tilt (~> 1.3, >= 1.3.4)
|
|
110
|
+
sprockets (2.12.1)
|
|
108
111
|
hike (~> 1.2)
|
|
112
|
+
multi_json (~> 1.0)
|
|
109
113
|
rack (~> 1.0)
|
|
110
114
|
tilt (~> 1.1, != 1.3.0)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
sprockets-rails (2.1.3)
|
|
116
|
+
actionpack (>= 3.0)
|
|
117
|
+
activesupport (>= 3.0)
|
|
118
|
+
sprockets (~> 2.8)
|
|
119
|
+
thor (0.19.1)
|
|
120
|
+
thread_safe (0.3.3)
|
|
121
|
+
tilt (1.4.1)
|
|
122
|
+
treetop (1.4.15)
|
|
114
123
|
polyglot
|
|
115
124
|
polyglot (>= 0.3.1)
|
|
116
|
-
tzinfo (
|
|
125
|
+
tzinfo (1.1.0)
|
|
126
|
+
thread_safe (~> 0.1)
|
|
117
127
|
vegas (0.1.11)
|
|
118
128
|
rack (>= 1.0.0)
|
|
119
|
-
webmock (1.
|
|
120
|
-
addressable (>= 2.
|
|
121
|
-
crack (>= 0.
|
|
129
|
+
webmock (1.18.0)
|
|
130
|
+
addressable (>= 2.3.6)
|
|
131
|
+
crack (>= 0.3.2)
|
|
122
132
|
|
|
123
133
|
PLATFORMS
|
|
124
134
|
ruby
|
|
125
135
|
|
|
126
136
|
DEPENDENCIES
|
|
127
137
|
heroku-resque-workers-scaler!
|
|
138
|
+
psych
|
|
128
139
|
rails
|
|
129
140
|
rake
|
|
130
141
|
rspec
|
data/{README.rdoc → README.md}
RENAMED
|
@@ -28,8 +28,19 @@ You can test when executed this :
|
|
|
28
28
|
```
|
|
29
29
|
HEROKU_API_KEY=your_api_key HEROKU_APP_NAME=your_app_name *** bundle exec *** rake spec
|
|
30
30
|
```
|
|
31
|
-
You can
|
|
32
|
-
|
|
31
|
+
You can change the thresholds, environments of execution and the name of your worker process in your project on config/scaler_config.yml
|
|
32
|
+
|
|
33
|
+
Exmple YAML file contents:
|
|
34
|
+
|
|
35
|
+
thresholds:
|
|
36
|
+
- :workers: 1
|
|
37
|
+
:job_count: 1
|
|
38
|
+
- :workers: 2
|
|
39
|
+
:job_count: 15
|
|
40
|
+
environments:
|
|
41
|
+
- production
|
|
42
|
+
worker_name: resque
|
|
43
|
+
|
|
33
44
|
I just bundled it into a gem for easy inclusion into other projects.
|
|
34
45
|
|
|
35
46
|
#### Usage
|
|
@@ -17,10 +17,11 @@ Gem::Specification.new do |gem|
|
|
|
17
17
|
gem.version = HerokuResqueAutoScale::VERSION
|
|
18
18
|
|
|
19
19
|
gem.add_runtime_dependency 'resque'
|
|
20
|
-
gem.add_runtime_dependency '
|
|
20
|
+
gem.add_runtime_dependency 'platform-api'
|
|
21
21
|
|
|
22
22
|
gem.add_development_dependency 'rails'
|
|
23
23
|
gem.add_development_dependency 'rspec'
|
|
24
24
|
gem.add_development_dependency 'webmock'
|
|
25
25
|
gem.add_development_dependency 'rake'
|
|
26
|
+
gem.add_development_dependency 'psych'
|
|
26
27
|
end
|
|
@@ -6,7 +6,7 @@ module HerokuResqueAutoScale
|
|
|
6
6
|
|
|
7
7
|
def thresholds
|
|
8
8
|
@thresholds ||= begin
|
|
9
|
-
if config_file?
|
|
9
|
+
if config_file? && config.has_key?('thresholds')
|
|
10
10
|
config['thresholds']
|
|
11
11
|
else
|
|
12
12
|
[{workers:1,job_count:1},{workers:2,job_count:15},{workers:3,job_count:25},{workers:4,job_count:40},{workers:5,job_count:60}]
|
|
@@ -16,13 +16,23 @@ module HerokuResqueAutoScale
|
|
|
16
16
|
|
|
17
17
|
def environments
|
|
18
18
|
@environments ||= begin
|
|
19
|
-
if config_file?
|
|
19
|
+
if config_file? && config.has_key?('environments')
|
|
20
20
|
config['environments']
|
|
21
21
|
else
|
|
22
22
|
[ 'production' ]
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
def worker_name
|
|
28
|
+
@worker_name ||= begin
|
|
29
|
+
if config_file? && config.has_key?('worker_name')
|
|
30
|
+
config['worker_name']
|
|
31
|
+
else
|
|
32
|
+
'worker'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
26
36
|
|
|
27
37
|
private
|
|
28
38
|
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'platform-api'
|
|
2
2
|
|
|
3
3
|
module HerokuResqueAutoScale
|
|
4
4
|
module Scaler
|
|
5
5
|
|
|
6
6
|
class << self
|
|
7
|
-
@@heroku =
|
|
7
|
+
@@heroku = PlatformAPI.connect(ENV['HEROKU_API_KEY'])
|
|
8
8
|
|
|
9
9
|
def workers
|
|
10
|
-
return
|
|
11
|
-
@@heroku.
|
|
10
|
+
return -1 unless authorized?
|
|
11
|
+
result = @@heroku.formation.info(app_name, worker_name)
|
|
12
|
+
result['quantity']
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
def workers=(
|
|
15
|
-
return unless
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
def workers=(quantity)
|
|
16
|
+
return unless authorized?
|
|
17
|
+
|
|
18
|
+
quantity = quantity.to_i
|
|
19
|
+
|
|
20
|
+
if safe_mode? and setting_this_number_of_workers_will_scale_down? quantity
|
|
21
|
+
return unless all_jobs_hve_been_processed?
|
|
18
22
|
end
|
|
19
|
-
@@heroku.
|
|
23
|
+
result = @@heroku.formation.update(app_name, worker_name, {quantity: quantity})
|
|
24
|
+
result['quantity'] == quantity
|
|
20
25
|
end
|
|
21
26
|
|
|
22
27
|
def job_count
|
|
@@ -29,24 +34,32 @@ module HerokuResqueAutoScale
|
|
|
29
34
|
|
|
30
35
|
protected
|
|
31
36
|
|
|
32
|
-
def
|
|
33
|
-
|
|
37
|
+
def app_name
|
|
38
|
+
ENV['HEROKU_APP_NAME']
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def setting_this_number_of_workers_will_scale_down? quantity
|
|
42
|
+
quantity < workers
|
|
34
43
|
end
|
|
35
44
|
|
|
36
45
|
def safe_mode?
|
|
37
46
|
ENV['SAFE_MODE'] and ENV['SAFE_MODE'] == 'true'
|
|
38
47
|
end
|
|
39
48
|
|
|
40
|
-
def
|
|
49
|
+
def all_jobs_hve_been_processed?
|
|
41
50
|
job_count + working_job_count == 0
|
|
42
51
|
end
|
|
43
52
|
|
|
44
53
|
private
|
|
45
54
|
|
|
46
|
-
def
|
|
55
|
+
def authorized?
|
|
47
56
|
HerokuResqueAutoScale::Config.environments.include? Rails.env.to_s
|
|
48
57
|
end
|
|
49
58
|
|
|
59
|
+
def worker_name
|
|
60
|
+
HerokuResqueAutoScale::Config.worker_name
|
|
61
|
+
end
|
|
62
|
+
|
|
50
63
|
end
|
|
51
64
|
end
|
|
52
65
|
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe HerokuResqueAutoScale::Config do
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
HerokuResqueAutoScale.send(:remove_const, 'Config')
|
|
7
|
+
load 'lib/heroku-resque-workers-scaler/config.rb'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context 'using the supplied config file' do
|
|
11
|
+
it { HerokuResqueAutoScale::Config.thresholds.should be_instance_of Array }
|
|
12
|
+
it { HerokuResqueAutoScale::Config.environments.should eql ['production','staging'] }
|
|
13
|
+
it { HerokuResqueAutoScale::Config.worker_name.should eql 'worker' }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context 'with missing config values' do
|
|
17
|
+
before :each do
|
|
18
|
+
HerokuResqueAutoScale::Config.stub(:config).and_return({})
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it { HerokuResqueAutoScale::Config.thresholds.should be_instance_of Array }
|
|
22
|
+
it { HerokuResqueAutoScale::Config.environments.should eql ['production'] }
|
|
23
|
+
it { HerokuResqueAutoScale::Config.worker_name.should eql 'worker' }
|
|
24
|
+
|
|
25
|
+
end
|
|
6
26
|
end
|
|
7
27
|
|
|
8
28
|
|
|
@@ -1,36 +1,51 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
# HEROKU_API_KEY=your_api_key HEROKU_APP_NAME=your_app_name bundle exec rake spec
|
|
4
3
|
describe HerokuResqueAutoScale::Scaler do
|
|
5
4
|
|
|
6
|
-
context 'authorised' do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
context 'when authorised' do
|
|
6
|
+
|
|
7
|
+
before { HerokuResqueAutoScale::Scaler.stub(:authorized?).and_return(true) }
|
|
8
|
+
|
|
9
|
+
context 'with safe mode disabled' do
|
|
10
|
+
|
|
11
|
+
before { HerokuResqueAutoScale::Scaler.stub(:safe_mode?).and_return(false) }
|
|
12
|
+
|
|
13
|
+
describe 'get number of workers' do
|
|
12
14
|
before do
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
|
|
15
|
+
response_hash = {
|
|
16
|
+
'command' => 'bundle exec rails server -p $PORT',
|
|
17
|
+
'created_at' => '2012-01-01T12:00:00Z',
|
|
18
|
+
'id' => '01234567-89ab-cdef-0123-456789abcdef',
|
|
19
|
+
'quantity' => 42,
|
|
20
|
+
'size' => '1X',
|
|
21
|
+
'type' => 'web',
|
|
22
|
+
'updated_at' => '2012-01-01T12:00:00Z'
|
|
23
|
+
}
|
|
24
|
+
PlatformAPI::Client.any_instance.stub_chain(:formation, :info).and_return(response_hash)
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
it { HerokuResqueAutoScale::Scaler.workers.should eql 42 }
|
|
20
28
|
end
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
describe 'set number of workers' do
|
|
23
31
|
before do
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
|
|
32
|
+
response_hash = {
|
|
33
|
+
'command' => 'bundle exec rails server -p $PORT',
|
|
34
|
+
'created_at' => '2012-01-01T12:00:00Z',
|
|
35
|
+
'id' => '01234567-89ab-cdef-0123-456789abcdef',
|
|
36
|
+
'quantity' => 69,
|
|
37
|
+
'size' => '1X',
|
|
38
|
+
'type' => 'web',
|
|
39
|
+
'updated_at' => '2012-01-01T12:00:00Z'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
PlatformAPI::Client.any_instance.stub_chain(:formation, :update).and_return(response_hash)
|
|
28
43
|
end
|
|
29
44
|
|
|
30
|
-
it { HerokuResqueAutoScale::Scaler.send(:workers=,
|
|
45
|
+
it { HerokuResqueAutoScale::Scaler.send(:workers=, 69).should be_true }
|
|
31
46
|
end
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
describe 'ask for job and working count' do
|
|
34
49
|
before { Resque.stub(info: { pending: '16', working: '61' }) }
|
|
35
50
|
|
|
36
51
|
it { HerokuResqueAutoScale::Scaler.job_count.should eql 16 }
|
|
@@ -38,30 +53,31 @@ describe HerokuResqueAutoScale::Scaler do
|
|
|
38
53
|
end
|
|
39
54
|
end
|
|
40
55
|
|
|
41
|
-
context '
|
|
56
|
+
context 'with safe mode enabled' do
|
|
42
57
|
before { HerokuResqueAutoScale::Scaler.stub safe_mode?: true }
|
|
43
|
-
|
|
44
|
-
context '
|
|
45
|
-
before { HerokuResqueAutoScale::Scaler.stub
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
|
|
59
|
+
context 'when about to scale down' do
|
|
60
|
+
before { HerokuResqueAutoScale::Scaler.stub setting_this_number_of_workers_will_scale_down?: true }
|
|
61
|
+
|
|
62
|
+
context 'when there are some jobs left to process' do
|
|
63
|
+
before { HerokuResqueAutoScale::Scaler.stub all_jobs_hve_been_processed?: false }
|
|
64
|
+
|
|
65
|
+
it 'does not trigger the API call' do
|
|
66
|
+
PlatformAPI::Client.any_instance.should_not_receive(:formation)
|
|
67
|
+
HerokuResqueAutoScale::Scaler.send(:workers=, '69')
|
|
68
|
+
end
|
|
50
69
|
end
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
to_return(:status => 200, :body => "", :headers => {})
|
|
70
|
+
|
|
71
|
+
context 'when there are no jobs left to process' do
|
|
72
|
+
before { HerokuResqueAutoScale::Scaler.stub all_jobs_hve_been_processed?: true }
|
|
73
|
+
|
|
74
|
+
describe 'should trigger action' do
|
|
75
|
+
it 'does not trigger the API call' do
|
|
76
|
+
mock_client = double(PlatformAPI::Client).as_null_object
|
|
77
|
+
PlatformAPI::Client.any_instance.should_receive(:formation).and_return(mock_client)
|
|
78
|
+
HerokuResqueAutoScale::Scaler.send(:workers=, '69')
|
|
79
|
+
end
|
|
62
80
|
end
|
|
63
|
-
|
|
64
|
-
it { HerokuResqueAutoScale::Scaler.send(:workers=, '69') }
|
|
65
81
|
end
|
|
66
82
|
end
|
|
67
83
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: heroku-resque-workers-scaler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Quezada
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '0'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
|
-
name:
|
|
29
|
+
name: platform-api
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
32
|
- - ">="
|
|
@@ -95,6 +95,20 @@ dependencies:
|
|
|
95
95
|
- - ">="
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
97
|
version: '0'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: psych
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
type: :development
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
98
112
|
description: Auto scale your resque workers on Heroku.
|
|
99
113
|
email:
|
|
100
114
|
- mark@mirthlab.com
|
|
@@ -111,10 +125,8 @@ files:
|
|
|
111
125
|
- Gemfile
|
|
112
126
|
- Gemfile.lock
|
|
113
127
|
- LICENSE.txt
|
|
114
|
-
- README.
|
|
128
|
+
- README.md
|
|
115
129
|
- Rakefile
|
|
116
|
-
- heroku-resque-workers-scaler-0.1.5.gem
|
|
117
|
-
- heroku-resque-workers-scaler-0.1.6.gem
|
|
118
130
|
- heroku-resque-workers-scaler.gemspec
|
|
119
131
|
- lib/heroku-resque-workers-scaler.rb
|
|
120
132
|
- lib/heroku-resque-workers-scaler/config.rb
|
|
Binary file
|
|
Binary file
|