Sha256: 72282171562ddbe83ffa641d1660b7435ff17988367c104887f87e3d02843666

Contents?: true

Size: 605 Bytes

Versions: 2

Compression:

Stored size: 605 Bytes

Contents

# encoding: utf-8

module DynoScaler
  class Heroku
    attr_accessor :application, :options

    def initialize(application, options={})
      self.application = application
      self.options     = options || {}
    end

    def scale_workers(quantity)
      heroku_client.post_ps_scale(application, 'worker', quantity)
    end

    def running_workers
      heroku_client.get_ps(application).body.select do |process|
        process['process'].start_with?('worker')
      end.count
    end

    protected
      def heroku_client
        @heroku_client ||= ::Heroku::API.new(options)
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dyno_scaler-0.3.0 lib/dyno_scaler/heroku.rb
dyno_scaler-0.2.0 lib/dyno_scaler/heroku.rb