class SidekiqHerokuScaler::Heroku::Client

Attributes

heroku_app_name[R]
heroku_token[R]

Public Class Methods

new(heroku_app_name, heroku_token) click to toggle source
# 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

Public Instance Methods

formation_for(worker_name) click to toggle source
# 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 } || {}
  )
end
formations() click to toggle source
# File lib/sidekiq-heroku-scaler/heroku/client.rb, line 14
def formations
  @formations ||= formation.list(heroku_app_name)
end
sidekiq_workers() click to toggle source
# File lib/sidekiq-heroku-scaler/heroku/client.rb, line 24
def sidekiq_workers
  @sidekiq_workers ||= begin
    formations.select { |formation| formation['command'].match(/sidekiq/) }
              .map { |formation| formation['type'] }
  end
end
update_formation(formation_id, quantity) click to toggle source
# File lib/sidekiq-heroku-scaler/heroku/client.rb, line 31
def update_formation(formation_id, quantity)
  formation.update(heroku_app_name, formation_id, quantity: quantity)
end

Private Instance Methods

client() click to toggle source
# File lib/sidekiq-heroku-scaler/heroku/client.rb, line 39
def client
  @client ||= PlatformAPI.connect_oauth(heroku_token)
end
formation() click to toggle source
# File lib/sidekiq-heroku-scaler/heroku/client.rb, line 43
def formation
  @formation ||= PlatformAPI::Formation.new(client)
end