heroku-resque-workers-scaler 0.3.0 → 0.3.1
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/.coveralls.yml +1 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +9 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +22 -1
- data/README.md +10 -0
- data/lib/heroku-resque-workers-scaler/scaler.rb +12 -4
- data/lib/heroku-resque-workers-scaler/version.rb +1 -1
- data/spec/heroku-resque-workers-scaler/scaler_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ee8ee0ed0f37c02accec1a1ee9edf01609bf884
|
4
|
+
data.tar.gz: a0ba98bd4f554f905a534de5c7bccbf43f5e0575
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfaa5aef014100ab64f24a8adbe7245c994741ade4225894d459fd551417e828555677c27427e7295fe062d52c5b352a853bcc866774aef81031ee2902c82c8d
|
7
|
+
data.tar.gz: edf368619612f0293b8f9ab21efa4bcdf859778b38265742a6e56ea249a20c54437e2c27d18e8a8120ef4c38d9d5fa321438345eecd5affe7dd11224e192203f
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --fail-fast
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
# Changelog VERSION = '0.3.1'
|
2
|
+
|
3
|
+
* bug fix
|
4
|
+
* we never can be scale down worker on safe mode
|
5
|
+
|
6
|
+
[Fullcahnges](https://github.com/joel/heroku-resque-workers-scaler/pull/9)
|
7
|
+
|
1
8
|
# Changelog VERSION = '0.3.0'
|
2
|
-
* feature
|
9
|
+
* feature
|
3
10
|
* Add another mode for thresholds
|
4
|
-
|
11
|
+
|
5
12
|
* bug fix
|
6
13
|
* fix size of working job count at ZERO instead of one
|
7
14
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
heroku-resque-workers-scaler (0.3.
|
4
|
+
heroku-resque-workers-scaler (0.3.1)
|
5
5
|
platform-api (~> 0.2.0)
|
6
6
|
resque (~> 1.25.2)
|
7
7
|
|
@@ -10,9 +10,16 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
addressable (2.3.6)
|
12
12
|
coderay (1.1.0)
|
13
|
+
coveralls (0.7.1)
|
14
|
+
multi_json (~> 1.3)
|
15
|
+
rest-client
|
16
|
+
simplecov (>= 0.7)
|
17
|
+
term-ansicolor
|
18
|
+
thor
|
13
19
|
crack (0.4.2)
|
14
20
|
safe_yaml (~> 1.0.0)
|
15
21
|
diff-lcs (1.2.5)
|
22
|
+
docile (1.1.5)
|
16
23
|
erubis (2.7.0)
|
17
24
|
excon (0.39.5)
|
18
25
|
heroics (0.0.12)
|
@@ -22,6 +29,7 @@ GEM
|
|
22
29
|
multi_json (>= 1.9.2)
|
23
30
|
netrc
|
24
31
|
method_source (0.8.2)
|
32
|
+
mime-types (2.3)
|
25
33
|
moneta (0.8.0)
|
26
34
|
mono_logger (1.1.0)
|
27
35
|
multi_json (1.10.1)
|
@@ -46,6 +54,9 @@ GEM
|
|
46
54
|
redis-namespace (~> 1.3)
|
47
55
|
sinatra (>= 0.9.2)
|
48
56
|
vegas (~> 0.1.2)
|
57
|
+
rest-client (1.7.2)
|
58
|
+
mime-types (>= 1.16, < 3.0)
|
59
|
+
netrc (~> 0.7)
|
49
60
|
rspec (3.1.0)
|
50
61
|
rspec-core (~> 3.1.0)
|
51
62
|
rspec-expectations (~> 3.1.0)
|
@@ -59,12 +70,21 @@ GEM
|
|
59
70
|
rspec-support (~> 3.1.0)
|
60
71
|
rspec-support (3.1.0)
|
61
72
|
safe_yaml (1.0.3)
|
73
|
+
simplecov (0.9.0)
|
74
|
+
docile (~> 1.1.0)
|
75
|
+
multi_json
|
76
|
+
simplecov-html (~> 0.8.0)
|
77
|
+
simplecov-html (0.8.0)
|
62
78
|
sinatra (1.4.5)
|
63
79
|
rack (~> 1.4)
|
64
80
|
rack-protection (~> 1.4)
|
65
81
|
tilt (~> 1.3, >= 1.3.4)
|
66
82
|
slop (3.6.0)
|
83
|
+
term-ansicolor (1.3.0)
|
84
|
+
tins (~> 1.0)
|
85
|
+
thor (0.19.1)
|
67
86
|
tilt (1.4.1)
|
87
|
+
tins (1.3.3)
|
68
88
|
vegas (0.1.11)
|
69
89
|
rack (>= 1.0.0)
|
70
90
|
webmock (1.18.0)
|
@@ -75,6 +95,7 @@ PLATFORMS
|
|
75
95
|
ruby
|
76
96
|
|
77
97
|
DEPENDENCIES
|
98
|
+
coveralls
|
78
99
|
heroku-resque-workers-scaler!
|
79
100
|
pry
|
80
101
|
psych (~> 2.0.6)
|
data/README.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
[](https://codeclimate.com/github/joel/heroku-resque-workers-scaler)
|
2
|
+
|
3
|
+
[](https://gemnasium.com/joel/heroku-resque-workers-scaler)
|
4
|
+
|
5
|
+
[](https://travis-ci.org/joel/heroku-resque-workers-scaler) (Travis CI)
|
6
|
+
|
7
|
+
[](https://coveralls.io/r/joel/heroku-resque-workers-scaler)
|
8
|
+
|
9
|
+
[](http://badge.fury.io/rb/heroku-resque-workers-scaler)
|
10
|
+
|
1
11
|
# heroku-resque-workers-scaler
|
2
12
|
|
3
13
|
Auto scale your resque workers on Heroku. Original code by darkhelmet:
|
@@ -18,13 +18,21 @@ module HerokuResqueAutoScale
|
|
18
18
|
|
19
19
|
quantity = quantity.to_i
|
20
20
|
|
21
|
-
if safe_mode?
|
22
|
-
|
21
|
+
if safe_mode?
|
22
|
+
if scale_down? quantity
|
23
|
+
return false unless all_jobs_have_been_processed?
|
24
|
+
end
|
23
25
|
end
|
26
|
+
|
24
27
|
result = @@heroku.formation.update(app_name, worker_name, { quantity: quantity })
|
25
28
|
result['quantity'] == quantity
|
26
29
|
end
|
27
30
|
|
31
|
+
def shut_down_workers!
|
32
|
+
@@heroku.formation.update(app_name, worker_name, { quantity: 0 })
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
28
36
|
def job_count
|
29
37
|
Resque.info[:pending].to_i
|
30
38
|
end
|
@@ -39,7 +47,7 @@ module HerokuResqueAutoScale
|
|
39
47
|
ENV['HEROKU_APP_NAME']
|
40
48
|
end
|
41
49
|
|
42
|
-
def
|
50
|
+
def scale_down? quantity
|
43
51
|
quantity < workers
|
44
52
|
end
|
45
53
|
|
@@ -110,6 +118,6 @@ module HerokuResqueAutoScale
|
|
110
118
|
def scale_down
|
111
119
|
# Nothing fancy, just shut everything down if we have no pending jobs
|
112
120
|
# and one working job (which is this job)
|
113
|
-
Scaler.
|
121
|
+
Scaler.shut_down_workers! if Scaler.job_count.zero? && Scaler.working_job_count <= 1
|
114
122
|
end
|
115
123
|
end
|
@@ -54,7 +54,7 @@ describe HerokuResqueAutoScale::Scaler do
|
|
54
54
|
before { allow(HerokuResqueAutoScale::Scaler).to receive(:safe_mode?) { true }}
|
55
55
|
|
56
56
|
context 'when about to scale down' do
|
57
|
-
before { allow(HerokuResqueAutoScale::Scaler).to receive(:
|
57
|
+
before { allow(HerokuResqueAutoScale::Scaler).to receive(:scale_down?) { true }}
|
58
58
|
|
59
59
|
context 'when there are some jobs left to process' do
|
60
60
|
before { allow(HerokuResqueAutoScale::Scaler).to receive(:all_jobs_have_been_processed?) { false }}
|
data/spec/spec_helper.rb
CHANGED
@@ -2,12 +2,15 @@ require 'heroku-resque-workers-scaler'
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
4
|
require 'resque'
|
5
|
+
require 'coveralls'
|
5
6
|
|
6
7
|
begin
|
7
8
|
require 'pry'
|
8
9
|
rescue LoadError
|
9
10
|
end
|
10
11
|
|
12
|
+
Coveralls.wear!
|
13
|
+
|
11
14
|
RSpec.configure do |config|
|
12
15
|
config.mock_with :rspec
|
13
16
|
end
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Quezada
|
@@ -103,9 +103,12 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
+
- ".coveralls.yml"
|
106
107
|
- ".document"
|
107
108
|
- ".gitignore"
|
109
|
+
- ".rspec"
|
108
110
|
- ".rvmrc"
|
111
|
+
- ".travis.yml"
|
109
112
|
- CHANGELOG.md
|
110
113
|
- COMMANDS
|
111
114
|
- Gemfile
|