Module OpenWFE::TimeoutMixin
In: lib/openwfe/expressions/timeout.rb

The timeout behaviour is implemented here, making it easy to mix it in into ParticipantExpression and WhenExpression.

Methods

Included Modules

Rufus::Schedulable

Attributes

timeout_at  [RW] 
timeout_job_id  [RW] 

Public Instance methods

Looks for the "timeout" attribute in its process definition and then sets the @timeout_at field (if there is a timeout).

[Source]

    # File lib/openwfe/expressions/timeout.rb, line 64
64:         def determine_timeout (timeout_attname=:timeout)
65: 
66:             #@timeout_at = nil
67:             #@timeout_job_id = nil
68: 
69:             timeout = lookup_attribute(timeout_attname, @applied_workitem)
70:             return unless timeout
71: 
72:             timeout = Rufus::parse_time_string(timeout)
73:             @timeout_at = Time.new.to_f + timeout
74:         end

Removes any "timed_out" field in the workitem.

[Source]

     # File lib/openwfe/expressions/timeout.rb, line 118
118:         def remove_timedout_flag (workitem)
119: 
120:             workitem.attributes.delete("__timed_out__")
121:         end

Providing a default reschedule() implementation for the expressions that use this mixin. This default implementation just reschedules the timeout.

[Source]

    # File lib/openwfe/expressions/timeout.rb, line 81
81:         def reschedule (scheduler)
82:             to_reschedule(scheduler)
83:         end

Combines a call to determine_timeout and to reschedule.

[Source]

    # File lib/openwfe/expressions/timeout.rb, line 88
88:         def schedule_timeout (timeout_attname=:timeout)
89: 
90:             determine_timeout(timeout_attname)
91:             to_reschedule(get_scheduler)
92:         end

Places a "timed_out" field in the workitem.

[Source]

     # File lib/openwfe/expressions/timeout.rb, line 110
110:         def set_timedout_flag (workitem)
111: 
112:             workitem.attributes["__timed_out__"] = "true"
113:         end

Protected Instance methods

prefixed with "to_" for easy mix in

[Source]

     # File lib/openwfe/expressions/timeout.rb, line 128
128:             def to_reschedule (scheduler)
129: 
130:                 #return if @timeout_job_id
131:                     #
132:                     # already rescheduled
133: 
134:                 return unless @timeout_at
135:                     #
136:                     # no need for a timeout
137: 
138:                 @timeout_job_id = "timeout_#{self.fei.to_s}"
139: 
140:                 scheduler.schedule_at(
141:                     @timeout_at, 
142:                     { :schedulable => self, 
143:                       :job_id => @timeout_job_id,
144:                       :do_timeout! => true,
145:                       :tags => [ "timeout", self.class.name ] })
146: 
147:                 ldebug do 
148:                     "to_reschedule() will timeout at " +
149:                     "#{Rufus::to_iso8601_date(@timeout_at)}" +
150:                     " @timeout_job_id is #{@timeout_job_id}" +
151:                     " (oid #{object_id})"
152:                 end
153: 
154:                 #store_itself()
155:                     #
156:                     # done in the including expression
157:             end

Unschedules the timeout

[Source]

     # File lib/openwfe/expressions/timeout.rb, line 162
162:             def unschedule_timeout ()
163: 
164:                 ldebug do 
165:                     "unschedule_timeout() " +
166:                     "@timeout_job_id is #{@timeout_job_id}" +
167:                     " (oid #{object_id})"
168:                 end
169: 
170:                 #ldebug_callstack "unschedule_timeout()"
171: 
172:                 get_scheduler.unschedule(@timeout_job_id) \
173:                     if @timeout_job_id
174:             end

[Validate]