Module: HerokuDelayedJobAutoscale::Autoscale

Defined in:
lib/heroku_delayed_job_autoscale.rb

Constant Summary collapse

@@autoscale_manager =
HerokuDelayedJobAutoscale::Manager::Local

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.autoscale_managerObject



11
12
13
# File 'lib/heroku_delayed_job_autoscale.rb', line 11

def self.autoscale_manager
  @@autoscale_manager
end

.autoscale_manager=(manager) ⇒ Object



15
16
17
# File 'lib/heroku_delayed_job_autoscale.rb', line 15

def self.autoscale_manager=(manager)
  @@autoscale_manager = manager
end

Instance Method Details

#after(job) ⇒ Object



33
34
35
# File 'lib/heroku_delayed_job_autoscale.rb', line 33

def after(job)
  autoscale_after(job)
end

#autoscale_after(job) ⇒ Object



37
38
39
40
# File 'lib/heroku_delayed_job_autoscale.rb', line 37

def autoscale_after(job)
  # after is triggered before the job is removed, hence we see if this is the last job
  autoscale_client.scale_down unless job.class.count - 1  > 0
end

#autoscale_enqueue(job) ⇒ Object



23
24
25
26
27
# File 'lib/heroku_delayed_job_autoscale.rb', line 23

def autoscale_enqueue(job)
  if autoscale_client.qty.zero?
    autoscale_client.scale_up
  end
end

#enqueue(job) ⇒ Object



19
20
21
# File 'lib/heroku_delayed_job_autoscale.rb', line 19

def enqueue(job)
  autoscale_enqueue(job)
end

#performObject



29
30
31
# File 'lib/heroku_delayed_job_autoscale.rb', line 29

def perform
  raise "Not implemented"
end