Class: Autoscaler::HerokuScaler
- Inherits:
-
Object
- Object
- Autoscaler::HerokuScaler
- Defined in:
- lib/autoscaler/heroku_scaler.rb
Overview
Wraps the Heroku API to provide just the interface that we need for scaling.
OBSOLETE: The v1 Heroku API is no longer available, and HerokuScaler will likely be removed in a future major release. Please see current setup instructions and examples for HerokuPlatformScaler.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#exception_handler ⇒ Object
writeonly
Callable object which responds to exceptions during api calls #.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#counter_cache=(cache) ⇒ Object
Object which supports #counter and #counter= Defaults to CounterCacheMemory.
-
#initialize(type = 'worker', key = ENV['HEROKU_API_KEY'], app = ENV['HEROKU_APP']) ⇒ HerokuScaler
constructor
A new instance of HerokuScaler.
-
#workers ⇒ Numeric
Read the current worker count (value may be cached).
-
#workers=(n) ⇒ Object
Set the number of workers (noop if workers the same).
Constructor Details
#initialize(type = 'worker', key = ENV['HEROKU_API_KEY'], app = ENV['HEROKU_APP']) ⇒ HerokuScaler
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/autoscaler/heroku_scaler.rb', line 11 def initialize( type = 'worker', key = ENV['HEROKU_API_KEY'], app = ENV['HEROKU_APP']) warn "Autoscaler: The v1 Heroku API is no longer available, and HerokuScaler will likely be removed in a future major release. Please see current setup instructions and examples for HerokuPlatformScaler." @client = Heroku::API.new(:api_key => key) @type = type @app = app @workers = CounterCacheMemory.new end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
24 25 26 |
# File 'lib/autoscaler/heroku_scaler.rb', line 24 def app @app end |
#exception_handler=(value) ⇒ Object
Callable object which responds to exceptions during api calls #
54 55 56 |
# File 'lib/autoscaler/heroku_scaler.rb', line 54 def exception_handler=(value) @exception_handler = value end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'lib/autoscaler/heroku_scaler.rb', line 25 def type @type end |
Instance Method Details
#counter_cache=(cache) ⇒ Object
Object which supports #counter and #counter= Defaults to CounterCacheMemory
58 59 60 |
# File 'lib/autoscaler/heroku_scaler.rb', line 58 def counter_cache=(cache) @workers = cache end |
#workers ⇒ Numeric
Read the current worker count (value may be cached)
29 30 31 |
# File 'lib/autoscaler/heroku_scaler.rb', line 29 def workers @workers.counter {@workers.counter = heroku_get_workers} end |
#workers=(n) ⇒ Object
Set the number of workers (noop if workers the same)
35 36 37 38 39 40 41 42 43 |
# File 'lib/autoscaler/heroku_scaler.rb', line 35 def workers=(n) unknown = false current = @workers.counter{unknown = true; 1} if n != current || unknown p "Scaling #{type} to #{n}" heroku_set_workers(n) @workers.counter = n end end |