Class: OpenWFE::WaitingExpression
- Inherits:
-
TimeExpression
- Object
- ObjectWithMeta
- FlowExpression
- TimeExpression
- OpenWFE::WaitingExpression
- Includes:
- ConditionMixin, TimeoutMixin
- Defined in:
- lib/openwfe/expressions/time.rb
Overview
A parent class for WhenExpression and WaitExpression.
All the code for managing waiting for something to occur is concentrated here.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_FREQUENCY =
By default, classes extending this class do poll for their condition every 10 seconds.
"10s"- MIN_FREQUENCY =
Don’t go under 300 milliseconds.
0.300
Instance Attribute Summary collapse
-
#frequency ⇒ Object
Returns the value of attribute frequency.
Attributes included from TimeoutMixin
Attributes inherited from TimeExpression
#applied_workitem, #scheduler_job_id, #scheduler_tags
Attributes inherited from FlowExpression
#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation
Attributes included from Contextual
Class Method Summary collapse
-
.conditions(*attnames) ⇒ Object
Classes extending this WaitingExpression have a ‘conditions’ class method (like ‘attr_accessor’).
Instance Method Summary collapse
- #apply(workitem) ⇒ Object
-
#cancel ⇒ Object
Cancels this expression (takes care of unscheduling a timeout if there is one).
- #reply(workitem) ⇒ Object
- #reply_to_parent(workitem) ⇒ Object
- #reschedule(scheduler) ⇒ Object
- #trigger(params = {}) ⇒ Object
Methods included from TimeoutMixin
#determine_timeout, #remove_timedout_flag, #schedule_timeout, #set_timedout_flag
Methods included from ConditionMixin
#determine_condition_attribute, #eval_condition
Methods inherited from TimeExpression
Methods inherited from FlowExpression
#clean_children, #delete_variable, #dup_environment, #fetch_environment, #fetch_text_content, #get_binding, #get_environment, #get_parent, #get_root_environment, #has_attribute, #initialize, is_definition, is_definition?, #lookup_attribute, #lookup_attributes, #lookup_boolean_attribute, #lookup_comma_list_attribute, #lookup_downcase_attribute, #lookup_ref, #lookup_string_attribute, #lookup_sym_attribute, #lookup_value, #lookup_variable, #lookup_vf_attribute, names, #new_environment, new_exp, #owns_its_environment?, #paused?, #remove_child, #set_variable, #store_itself, #synchronize, #to_s, #to_yaml_properties
Methods included from Contextual
#get_work_directory, #init_service, #lookup
Methods included from Logging
#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn
Methods included from OwfeServiceLocator
#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator
Methods inherited from ObjectWithMeta
#class_def, meta_def, meta_eval, metaclass
Constructor Details
This class inherits a constructor from OpenWFE::FlowExpression
Instance Attribute Details
#frequency ⇒ Object
Returns the value of attribute frequency.
133 134 135 |
# File 'lib/openwfe/expressions/time.rb', line 133 def frequency @frequency end |
Class Method Details
.conditions(*attnames) ⇒ Object
Classes extending this WaitingExpression have a ‘conditions’ class method (like ‘attr_accessor’).
150 151 152 153 154 155 156 157 158 |
# File 'lib/openwfe/expressions/time.rb', line 150 def self.conditions (*attnames) attnames = attnames.collect do |n| n.to_s.intern end :condition_attributes do attnames end end |
Instance Method Details
#apply(workitem) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/openwfe/expressions/time.rb', line 160 def apply (workitem) remove_timedout_flag workitem @applied_workitem = workitem.dup @frequency = lookup_attribute( :frequency, workitem, :default => DEFAULT_FREQUENCY) @frequency = Rufus::parse_time_string( @frequency) @frequency = MIN_FREQUENCY \ if @frequency < MIN_FREQUENCY determine_timeout store_itself trigger end |
#cancel ⇒ Object
Cancels this expression (takes care of unscheduling a timeout if there is one).
196 197 198 199 200 |
# File 'lib/openwfe/expressions/time.rb', line 196 def cancel unschedule_timeout super() end |
#reply(workitem) ⇒ Object
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/openwfe/expressions/time.rb', line 181 def reply (workitem) result = workitem.get_result if result apply_consequence(workitem) else reschedule(get_scheduler) end end |
#reply_to_parent(workitem) ⇒ Object
236 237 238 239 240 241 242 |
# File 'lib/openwfe/expressions/time.rb', line 236 def reply_to_parent (workitem) unschedule unschedule_timeout super workitem end |
#reschedule(scheduler) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/openwfe/expressions/time.rb', line 220 def reschedule (scheduler) @scheduler_job_id = "waiting_#{fei.to_s}" scheduler.schedule_in( @frequency, { :schedulable => self, :job_id => @scheduler_job_id, :tags => }) ldebug { "reschedule() @scheduler_job_id is #{@scheduler_job_id}" } to_reschedule(scheduler) end |
#trigger(params = {}) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/openwfe/expressions/time.rb', line 202 def trigger (params={}) ldebug { "trigger() #{@fei.to_debug_s} params : #{params.inspect}" } if params[:do_timeout!] # # do timeout... # set_timedout_flag @applied_workitem reply_to_parent @applied_workitem return end @scheduler_job_id = nil evaluate_condition() end |