Class: ForemanInventoryUpload::Async::DelayAction

Inherits:
Actions::EntryAction
  • Object
show all
Defined in:
lib/foreman_inventory_upload/async/delayed_start.rb

Constant Summary collapse

Wake =
Algebrick.atom

Instance Method Summary collapse

Instance Method Details

#plan(delay) ⇒ Object



29
30
31
# File 'lib/foreman_inventory_upload/async/delayed_start.rb', line 29

def plan(delay)
  plan_self(delay: delay)
end

#run(event = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/foreman_inventory_upload/async/delayed_start.rb', line 33

def run(event = nil)
  case event
  when nil
    action_logger.debug("Going to sleep for #{sleep_seconds} seconds")
    plan_event(Wake, sleep_seconds)
    suspend
  when Wake
    action_logger.debug('Waking up')
  else
    action_logger.debug("DelayAction received unknown event #{event}")
  end
end

#sleep_secondsObject



46
47
48
# File 'lib/foreman_inventory_upload/async/delayed_start.rb', line 46

def sleep_seconds
  input[:delay].to_i
end