Class: Moon::Scheduler::Jobs::Timeout

Inherits:
TimeBase show all
Defined in:
lib/moon/packages/scheduler/jobs/timeout.rb

Overview

Timeouts are one off tasks which will execute after their time has expired.

Instance Attribute Summary collapse

Attributes inherited from TimeBase

#duration, #time

Attributes inherited from Base

#active, #id, #key, #killed, #uptime

Instance Method Summary collapse

Methods inherited from TimeBase

#finish, #initialize, #rate, #restart, #stop, #timeout?, #update_job, #update_job_step

Methods inherited from Base

#initialize, #kill, #killed?, #trigger_callback, #update, #update_job

Methods included from Activatable

#activate, #active?, #deactivate

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #trigger, #typing

Constructor Details

This class inherits a constructor from Moon::Scheduler::Jobs::TimeBase

Instance Attribute Details

#triggeredBoolean (readonly)

Whether this timeout has already called its trigger method.

Returns:


11
12
13
# File 'lib/moon/packages/scheduler/jobs/timeout.rb', line 11

def triggered
  @triggered
end

Instance Method Details

#done?Boolean

Has this timeout reached its end?

Returns:


16
17
18
# File 'lib/moon/packages/scheduler/jobs/timeout.rb', line 16

def done?
  timeout? && @triggered
end

#on_timeoutObject

When time reaches 0 or less


21
22
23
24
25
# File 'lib/moon/packages/scheduler/jobs/timeout.rb', line 21

def on_timeout
  trigger_callback
  @triggered = true
  deactivate
end