Module: OpenWFE::TimeoutMixin
- Includes:
- Rufus::Schedulable
- Included in:
- ListenExpression, ParticipantExpression, TimeoutExpression, WaitingExpression
- Defined in:
- lib/openwfe/expressions/timeout.rb
Overview
The timeout behaviour is implemented here, making it easy to mix it in into ParticipantExpression and WhenExpression.
Instance Attribute Summary collapse
-
#timeout_at ⇒ Object
Returns the value of attribute timeout_at.
-
#timeout_job_id ⇒ Object
Returns the value of attribute timeout_job_id.
Instance Method Summary collapse
-
#determine_timeout(timeout_attname = :timeout) ⇒ Object
Looks for the “timeout” attribute in its process definition and then sets the @timeout_at field (if there is a timeout).
-
#remove_timedout_flag(workitem) ⇒ Object
Removes any “timed_out” field in the workitem.
-
#reschedule(scheduler) ⇒ Object
Providing a default reschedule() implementation for the expressions that use this mixin.
-
#schedule_timeout(timeout_attname = :timeout) ⇒ Object
Combines a call to determine_timeout and to reschedule.
-
#set_timedout_flag(workitem) ⇒ Object
Places a “timed_out” field in the workitem.
Instance Attribute Details
#timeout_at ⇒ Object
Returns the value of attribute timeout_at.
56 57 58 |
# File 'lib/openwfe/expressions/timeout.rb', line 56 def timeout_at @timeout_at end |
#timeout_job_id ⇒ Object
Returns the value of attribute timeout_job_id.
56 57 58 |
# File 'lib/openwfe/expressions/timeout.rb', line 56 def timeout_job_id @timeout_job_id end |
Instance Method Details
#determine_timeout(timeout_attname = :timeout) ⇒ Object
Looks for the “timeout” attribute in its process definition and then sets the @timeout_at field (if there is a timeout).
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/openwfe/expressions/timeout.rb', line 64 def determine_timeout (timeout_attname=:timeout) #@timeout_at = nil #@timeout_job_id = nil timeout = lookup_attribute(timeout_attname, @applied_workitem) return unless timeout timeout = Rufus::parse_time_string(timeout) @timeout_at = Time.new.to_f + timeout end |
#remove_timedout_flag(workitem) ⇒ Object
Removes any “timed_out” field in the workitem.
118 119 120 121 |
# File 'lib/openwfe/expressions/timeout.rb', line 118 def remove_timedout_flag (workitem) workitem.attributes.delete("__timed_out__") end |
#reschedule(scheduler) ⇒ Object
Providing a default reschedule() implementation for the expressions that use this mixin. This default implementation just reschedules the timeout.
81 82 83 |
# File 'lib/openwfe/expressions/timeout.rb', line 81 def reschedule (scheduler) to_reschedule(scheduler) end |
#schedule_timeout(timeout_attname = :timeout) ⇒ Object
Combines a call to determine_timeout and to reschedule.
88 89 90 91 92 |
# File 'lib/openwfe/expressions/timeout.rb', line 88 def schedule_timeout (timeout_attname=:timeout) determine_timeout(timeout_attname) to_reschedule(get_scheduler) end |
#set_timedout_flag(workitem) ⇒ Object
Places a “timed_out” field in the workitem.
110 111 112 113 |
# File 'lib/openwfe/expressions/timeout.rb', line 110 def set_timedout_flag (workitem) workitem.attributes["__timed_out__"] = "true" end |