lib/ruote/exp/fe_participant.rb in ruote-2.1.9 vs lib/ruote/exp/fe_participant.rb in ruote-2.1.10
- old
+ new
@@ -21,11 +21,10 @@
#
# Made in Japan.
#++
-require 'ruote/workitem'
require 'ruote/exp/condition'
module Ruote::Exp
@@ -118,10 +117,14 @@
#include FilterMixin
# TODO
names :participant
+ # Should return true when the dispatch was successful.
+ #
+ h_reader :dispatched
+
def apply
#
# determine participant
@@ -155,37 +158,62 @@
@context.storage.put_msg(
'dispatch',
'fei' => h.fei,
'participant_name' => h.participant_name,
'workitem' => h.applied_workitem,
- 'for_engine_worker?' => participant_info.class != Array)
- #
- # NOTE : is this for_engine_worker? still necessary ?
+ 'for_engine_worker?' => (participant_info.class != Array))
end
def cancel (flavour)
+ return reply_to_parent(h.applied_workitem) unless h.participant_name
+ # no participant, reply immediately
+
do_persist || return
#
# if do_persist returns false, it means we're operating on stale
- # data and have thus to cease
+ # data and cannot continue
@context.storage.put_msg(
'dispatch_cancel',
'fei' => h.fei,
'participant_name' => h.participant_name,
'flavour' => flavour,
'workitem' => h.applied_workitem)
end
+ def reply (workitem)
+
+ pa = @context.plist.lookup(
+ workitem['participant_name'], :on_reply => true)
+
+ pa.on_reply(Ruote::Workitem.new(workitem)) if pa
+
+ super(workitem)
+ end
+
def reply_to_parent (workitem)
workitem['fields'].delete('params')
workitem['fields'].delete('dispatched_at')
super(workitem)
end
protected
+
+ # Once the dispatching work (done by the dispatch pool) is done, a
+ # 'dispatched' msg is sent, we have to flag the participant expression
+ # as 'dispatched' => true
+ #
+ # See http://groups.google.com/group/openwferu-users/browse_thread/thread/ff29f26d6b5fd135
+ # for the motivation.
+ #
+ def do_dispatched (msg)
+
+ h.dispatched = true
+ do_persist
+ # let's not care if it fails...
+ end
# Overriden with an empty behaviour. The work is now done a bit later
# via the #schedule_timeout method.
#
def consider_timeout