Class: Dynomatic::Scaler
- Inherits:
-
Object
- Object
- Dynomatic::Scaler
- Defined in:
- lib/dynomatic/scaler.rb
Instance Attribute Summary collapse
-
#heroku_token ⇒ Object
readonly
Returns the value of attribute heroku_token.
Instance Method Summary collapse
-
#initialize(heroku_token, heroku_app) ⇒ Scaler
constructor
A new instance of Scaler.
- #scale_to(dyno_count, type: "worker") ⇒ Object
- #start!(type) ⇒ Object
- #stop!(type) ⇒ Object
Constructor Details
#initialize(heroku_token, heroku_app) ⇒ Scaler
Returns a new instance of Scaler.
7 8 9 10 |
# File 'lib/dynomatic/scaler.rb', line 7 def initialize(heroku_token, heroku_app) @heroku_token = heroku_token @heroku_app = heroku_app end |
Instance Attribute Details
#heroku_token ⇒ Object (readonly)
Returns the value of attribute heroku_token.
5 6 7 |
# File 'lib/dynomatic/scaler.rb', line 5 def heroku_token @heroku_token end |
Instance Method Details
#scale_to(dyno_count, type: "worker") ⇒ Object
12 13 14 15 16 |
# File 'lib/dynomatic/scaler.rb', line 12 def scale_to(dyno_count, type: "worker") Rails.logger.info "Scaling #{type} to #{dyno_count}" client.formation.update(heroku_app, type, {quantity: dyno_count}) end |
#start!(type) ⇒ Object
18 19 20 |
# File 'lib/dynomatic/scaler.rb', line 18 def start!(type) scale_to(1, type: type) end |
#stop!(type) ⇒ Object
22 23 24 |
# File 'lib/dynomatic/scaler.rb', line 22 def stop!(type) scale_to(0, type: type) end |