lib/ruote/exp/fe_participant.rb in ruote-2.1.11 vs lib/ruote/exp/fe_participant.rb in ruote-2.2.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -89,11 +89,12 @@
#
# where alice as two days to complete her task (send back the workitem).
#
# But it's OK for participant classes registered in the engine to provide
# their own timeout value. The participant instance simply has to reply to
- # the #timeout method and provide a meaningful timeout value.
+ # the #rtimeout method and provide a meaningful timeout value (like a
+ # number of seconds, or a string like "2d" or "1M2w".
#
# Note however, that the process definition timeout (if any) will take
# precedence over the participant specified one.
#
#
@@ -112,13 +113,10 @@
# (after a few operations). By default, BlockParticipant instances do not
# thread.
#
class ParticipantExpression < FlowExpression
- #include FilterMixin
- # TODO
-
names :participant
# Should return true when the dispatch was successful.
#
h_reader :dispatched
@@ -164,15 +162,14 @@
@context.storage.put_msg(
'dispatch',
'fei' => h.fei,
'participant_name' => h.participant_name,
'participant' => h.participant,
- 'workitem' => h.applied_workitem,
- 'for_engine_worker?' => (participant_info.class != Array))
+ 'workitem' => h.applied_workitem)
end
- def cancel (flavour)
+ def cancel(flavour)
return reply_to_parent(h.applied_workitem) unless h.participant_name
# no participant, reply immediately
do_persist || return
@@ -187,11 +184,11 @@
'participant' => h.participant,
'flavour' => flavour,
'workitem' => h.applied_workitem)
end
- def reply (workitem)
+ def reply(workitem)
pinfo =
h.participant ||
@context.plist.lookup_info(h.participant_name, workitem)
@@ -200,11 +197,11 @@
pa.on_reply(Ruote::Workitem.new(workitem)) if pa
super(workitem)
end
- def reply_to_parent (workitem)
+ def reply_to_parent(workitem)
workitem['fields'].delete('params')
workitem['fields'].delete('dispatched_at')
super(workitem)
end
@@ -216,11 +213,11 @@
# as 'dispatched' => true
#
# See http://groups.google.com/group/openwferu-users/browse_thread/thread/ff29f26d6b5fd135
# for the motivation.
#
- def do_dispatched (msg)
+ def do_dispatched(msg)
h.dispatched = true
do_persist
# let's not care if it fails...
end
@@ -234,21 +231,21 @@
# Determines and schedules timeout if any.
#
# Note that process definition timeout has priority over participant
# specified timeout.
#
- def schedule_timeout (p_info)
+ def schedule_timeout(p_info)
timeout = attribute(:timeout)
unless timeout
- pa = @context.plist.instantiate(p_info, :if_respond_to? => :timeout)
+ pa = @context.plist.instantiate(p_info, :if_respond_to? => :rtimeout)
- timeout = pa.timeout if pa && pa.method(:timeout).arity == 0
- #
- # the arity check is for jruby which seems to have a timeout
- # method here and there
+ timeout = (pa.method(:rtimeout).arity == 0 ?
+ pa.rtimeout :
+ pa.rtimeout(Ruote::Workitem.new(h.applied_workitem))
+ ) if pa
end
do_schedule_timeout(timeout)
end
end