Module: HerokuResqueAutoScale
- Defined in:
- lib/heroku-resque-workers-scaler/config.rb,
lib/heroku-resque-workers-scaler/scaler.rb,
lib/heroku-resque-workers-scaler/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.3.1'
Instance Method Summary collapse
- #after_enqueue_scale_up(*args) ⇒ Object
- #after_perform_scale_down(*args) ⇒ Object
- #on_failure_scale_down(exception, *args) ⇒ Object
Instance Method Details
#after_enqueue_scale_up(*args) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/heroku-resque-workers-scaler/scaler.rb', line 91 def after_enqueue_scale_up(*args) case Config.mode when :thresholds Config.thresholds.reverse_each do |scale_info| # Run backwards so it gets set to the highest value first # Otherwise if there were 70 jobs, it would get set to 1, then 2, then 3, etc # If we have a job count greater than or equal to the job limit for this scale info if Scaler.job_count >= scale_info[:job_count] # Set the number of workers unless they are already set to a level we want. Don't scale down here! if Scaler.workers <= scale_info[:workers] Scaler.workers = scale_info[:workers] end break # We've set or ensured that the worker count is high enough end end when :fit Scaler.workers = Scaler.job_count when :half Scaler.workers = (Scaler.job_count/2) when :third Scaler.workers = (Scaler.job_count/3) end end |
#after_perform_scale_down(*args) ⇒ Object
83 84 85 |
# File 'lib/heroku-resque-workers-scaler/scaler.rb', line 83 def after_perform_scale_down(*args) scale_down end |
#on_failure_scale_down(exception, *args) ⇒ Object
87 88 89 |
# File 'lib/heroku-resque-workers-scaler/scaler.rb', line 87 def on_failure_scale_down(exception, *args) scale_down end |