Class: JobsAutoscaling::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/jobs_autoscaling/monitor.rb

Constant Summary collapse

IDLE =
:idle
BUSY =
:busy

Instance Method Summary collapse

Constructor Details

#initialize(action:) ⇒ Monitor

Returns a new instance of Monitor.



8
9
10
# File 'lib/jobs_autoscaling/monitor.rb', line 8

def initialize(action: )
  @actions = Array(action)
end

Instance Method Details

#activate!Object



12
13
14
15
16
# File 'lib/jobs_autoscaling/monitor.rb', line 12

def activate!
  Delayed::Worker.lifecycle.after(:check_for_work, &method(:check_for_work))
  load_preexisting_jobs
  change_state(preexisting_jobs_running? ? BUSY : IDLE)
end