Module: HerokuResqueAutoscaler
- Defined in:
- lib/heroku_resque_autoscaler.rb,
lib/heroku_resque_autoscaler/scaler.rb,
lib/heroku_resque_autoscaler/version.rb,
lib/heroku_resque_autoscaler/configuration.rb
Defined Under Namespace
Modules: Scaler Classes: Configuration
Constant Summary collapse
- DEFAULT_WORKER_SCALE =
[ { :workers => 1, :job_count => 1 }, { :workers => 2, :job_count => 15 }, { :workers => 3, :job_count => 25 }, { :workers => 4, :job_count => 40 }, { :workers => 5, :job_count => 60 } ]
- VERSION =
"0.2.0"
Class Attribute Summary collapse
-
.configuration ⇒ Object
The configuration object.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
Instance Method Summary collapse
- #after_enqueue_scale_up(*args) ⇒ Object
- #after_perform_scale_down(*args) ⇒ Object
- #num_desired_heroku_workers(*args) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
The configuration object.
24 25 26 |
# File 'lib/heroku_resque_autoscaler.rb', line 24 def configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
35 36 37 |
# File 'lib/heroku_resque_autoscaler.rb', line 35 def configure yield(configuration) end |
Instance Method Details
#after_enqueue_scale_up(*args) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/heroku_resque_autoscaler.rb', line 40 def after_enqueue_scale_up(*args) desired_workers = num_desired_heroku_workers if Scaler.workers < desired_workers Scaler.workers = desired_workers end end |
#after_perform_scale_down(*args) ⇒ Object
47 48 49 50 |
# File 'lib/heroku_resque_autoscaler.rb', line 47 def after_perform_scale_down(*args) # Scale everything down if we have no pending jobs and one working job (this one) Scaler.workers = 0 if Scaler.job_count.zero? && Scaler.working_job_count == 1 end |