Class: SidekiqHerokuScaler::Heroku::Client
- Inherits:
-
Object
- Object
- SidekiqHerokuScaler::Heroku::Client
- Defined in:
- lib/sidekiq-heroku-scaler/heroku/client.rb
Instance Method Summary collapse
- #formation_for(worker_name) ⇒ Object
- #formations ⇒ Object
-
#initialize(heroku_app_name, heroku_token) ⇒ Client
constructor
A new instance of Client.
- #sidekiq_workers ⇒ Object
- #update_formation(formation_id, quantity) ⇒ Object
Constructor Details
#initialize(heroku_app_name, heroku_token) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/sidekiq-heroku-scaler/heroku/client.rb', line 9 def initialize(heroku_app_name, heroku_token) @heroku_app_name = heroku_app_name @heroku_token = heroku_token end |
Instance Method Details
#formation_for(worker_name) ⇒ Object
18 19 20 21 22 |
# File 'lib/sidekiq-heroku-scaler/heroku/client.rb', line 18 def formation_for(worker_name) SidekiqHerokuScaler::Heroku::Formation.new( formations.detect { |formation| formation['type'] == worker_name.to_s } || {} ) end |
#formations ⇒ Object
14 15 16 |
# File 'lib/sidekiq-heroku-scaler/heroku/client.rb', line 14 def formations @formations ||= formation.list(heroku_app_name) end |
#sidekiq_workers ⇒ Object
24 25 26 27 |
# File 'lib/sidekiq-heroku-scaler/heroku/client.rb', line 24 def sidekiq_workers @sidekiq_workers ||= formations.select { |formation| formation['command'].include?('sidekiq') } .map { |formation| formation['type'] } end |
#update_formation(formation_id, quantity) ⇒ Object
29 30 31 |
# File 'lib/sidekiq-heroku-scaler/heroku/client.rb', line 29 def update_formation(formation_id, quantity) formation.update(heroku_app_name, formation_id, quantity: quantity) end |