Module: Resque::Plugins::ScalingCanary

Defined in:
lib/resque/plugins/resque_heroku_scaling_canary.rb,
lib/resque/plugins/resque_heroku_scaling_canary/config.rb,
lib/resque/plugins/resque_heroku_scaling_canary/canary_job.rb

Defined Under Namespace

Modules: Config Classes: CanaryJob

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config {|Config| ... } ⇒ Object

Yields:



16
17
18
# File 'lib/resque/plugins/resque_heroku_scaling_canary.rb', line 16

def self.config
  yield Config
end

Instance Method Details

#after_enqueue_ensure_heroku_workers(*args) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/resque/plugins/resque_heroku_scaling_canary.rb', line 8

def after_enqueue_ensure_heroku_workers(*args)
  return if Config.scaling_disabled?
  n = self.respond_to?(:minimum_workers_needed) ? self.minimum_workers_needed : 1
  return if Config.heroku_client.info(Config.heroku_app)[:workers].to_i >= n
  Config.heroku_client.ps_scale(Config.heroku_app, :type => "worker", :qty => n)
  Resque.enqueue(CanaryJob, Config.polling_interval) if CanaryJob.canary_jobs_outstanding == 0
end