Module: HerokuResqueAutoscaler::Scaler
- Defined in:
- lib/heroku_resque_autoscaler/scaler.rb
Class Method Summary collapse
- .api_key ⇒ Object
- .app_name ⇒ Object
- .heroku ⇒ Object
- .job_count ⇒ Object
- .max_resque_workers ⇒ Object
- .workers ⇒ Object
- .workers=(qty) ⇒ Object
- .working_job_count ⇒ Object
Class Method Details
.api_key ⇒ Object
11 12 13 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 11 def api_key HerokuResqueAutoscaler.configuration["heroku_api_key"] end |
.app_name ⇒ Object
15 16 17 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 15 def app_name HerokuResqueAutoscaler.configuration["heroku_app_name"] end |
.heroku ⇒ Object
7 8 9 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 7 def heroku @heroku ||= Heroku::API.new(api_key: api_key) end |
.job_count ⇒ Object
34 35 36 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 34 def job_count Resque.info[:pending].to_i end |
.max_resque_workers ⇒ Object
19 20 21 22 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 19 def max_resque_workers return Float::INFINITY unless HerokuResqueAutoscaler.configuration["max_resque_workers"] HerokuResqueAutoscaler.configuration["max_resque_workers"].to_i end |
.workers ⇒ Object
24 25 26 27 28 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 24 def workers heroku.get_ps(app_name).body.keep_if do |ps| ps["process"] =~ /worker/ end.length.to_i end |
.workers=(qty) ⇒ Object
30 31 32 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 30 def workers=(qty) heroku.post_ps_scale(app_name, :worker, qty) end |
.working_job_count ⇒ Object
38 39 40 |
# File 'lib/heroku_resque_autoscaler/scaler.rb', line 38 def working_job_count Resque.info[:working].to_i end |