Class: OpenWFE::TimeoutExpression

Inherits:
FlowExpression show all
Includes:
TimeoutMixin
Defined in:
lib/openwfe/expressions/fe_timeout.rb

Overview

The timeout concept begun with the participant expression. When a participant doesn’t reply for a certain amount of time, a specified timeout can get triggered. Sometimes something more complex than a single participant needs a timeout setting, this expression sets a timeout for the expression nested within it.

<timeout after="2d">
    <sequence>
        (...)
    </sequence>
</timeout>

Instance Attribute Summary collapse

Attributes included from TimeoutMixin

#timeout_at, #timeout_job_id

Attributes inherited from FlowExpression

#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation

Attributes included from Contextual

#application_context

Instance Method Summary collapse

Methods included from TimeoutMixin

#determine_timeout, #remove_timedout_flag, #reschedule, #schedule_timeout, #set_timedout_flag

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, #reply_to_parent, #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

#applied_workitemObject

Returns the value of attribute applied_workitem.



70
71
72
# File 'lib/openwfe/expressions/fe_timeout.rb', line 70

def applied_workitem
  @applied_workitem
end

Instance Method Details

#apply(workitem) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/openwfe/expressions/fe_timeout.rb', line 72

def apply (workitem)

    if @children.size < 1
        reply_to_parent workitem
        return
    end

    @applied_workitem = workitem.dup

    schedule_timeout(:after)

    get_expression_pool.apply @children[0], workitem
end

#cancelObject

Cancel order : cancels the child expression (if applied) and unschedule the timeout (if any).



101
102
103
104
105
106
107
108
# File 'lib/openwfe/expressions/fe_timeout.rb', line 101

def cancel

    get_expression_pool.cancel(@children[0]) if @applied_workitem

    unschedule_timeout()

    super
end

#reply(workitem) ⇒ Object

The child expression replies, make sure to unschedule the timeout before replying (to our own parent expression).



90
91
92
93
94
95
# File 'lib/openwfe/expressions/fe_timeout.rb', line 90

def reply (workitem)

    unschedule_timeout()

    super
end

#trigger(scheduler) ⇒ Object

The timeout trigger, cancels the nested process segment (the nested expression).



114
115
116
117
118
119
120
121
122
123
# File 'lib/openwfe/expressions/fe_timeout.rb', line 114

def trigger (scheduler)

    ldebug { "trigger() timeout requested for #{@fei.to_debug_s}" }

    set_timedout_flag(@applied_workitem)

    cancel()

    reply_to_parent @applied_workitem
end