lib/dyno_scaler/heroku.rb in dyno_scaler-0.1.0 vs lib/dyno_scaler/heroku.rb in dyno_scaler-0.2.0
- old
+ new
@@ -1,20 +1,27 @@
# encoding: utf-8
module DynoScaler
class Heroku
- attr_accessor :application
+ attr_accessor :application, :options
- def initialize(application)
+ 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
+ @heroku_client ||= ::Heroku::API.new(options)
end
end
end
\ No newline at end of file