lib/openwfe/expressions/timeout.rb in openwferu-0.9.6 vs lib/openwfe/expressions/timeout.rb in openwferu-0.9.7
- old
+ new
@@ -47,11 +47,10 @@
# Managing timeout for expressions like 'participant' and 'when'
#
module OpenWFE
-
#
# The timeout behaviour is implemented here, making it easy
# to mix it in into ParticipantExpression and WhenExpression.
#
module TimeoutMixin
@@ -59,10 +58,14 @@
attr_accessor \
:timeout_at,
:timeout_job_id
+ #
+ # Looks for the "timeout" attribute in its process definition
+ # and then sets the @timeout_at field (if there is a timeout).
+ #
def determine_timeout
#@timeout_at = nil
#@timeout_job_id = nil
@@ -71,27 +74,41 @@
timeout = OpenWFE::parse_time_string(timeout)
@timeout_at = Time.new.to_f + timeout
end
+ #
+ # Providing a default reschedule() implementation for the expressions
+ # that use this mixin.
+ # This default implementation just reschedules the timeout.
+ #
def reschedule (scheduler)
to_reschedule(scheduler)
end
#
# Overrides the parent method to make sure a potential
# timeout schedules gets removed.
#
- def reply_to_parent (workitem)
- unschedule_timeout()
- super(workitem)
- end
+ # Well... Leave that to classes that mix this in...
+ # No method override in a mixin...
+ #
+ #def reply_to_parent (workitem)
+ # unschedule_timeout()
+ # super(workitem)
+ #end
+ #
+ # Places a "__timed_out__" field in the workitem.
+ #
def set_timedout_flag (workitem)
workitem.attributes["__timed_out__"] = "true"
end
+ #
+ # Removes any "__timed_out__" field in the workitem.
+ #
def remove_timedout_flag (workitem)
workitem.attributes.delete("__timed_out__")
end
protected
@@ -120,10 +137,20 @@
#store_itself()
#
# done in the including expression
end
+ #
+ # Unschedules the timeout
+ #
def unschedule_timeout ()
+
+ ldebug do
+ "unschedule_timeout() " +
+ "@timeout_job_id is #{@timeout_job_id}"
+ end
+
+ #ldebug_callstack "unschedule_timeout()"
get_scheduler.unschedule(@timeout_job_id) \
if @timeout_job_id
end
end