lib/ruote/part/local_participant.rb in ruote-2.1.11 vs lib/ruote/part/local_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
@@ -49,11 +49,11 @@
# Look at the unschedule_re_dispatch method for an example of
# participant implementation that uses re_dispatch.
#
# Without one of those options, the method is a "reject".
#
- def re_dispatch (workitem, opts={})
+ def re_dispatch(workitem, opts={})
msg = {
'action' => 'dispatch',
'fei' => workitem.h.fei,
'workitem' => workitem.h,
@@ -80,46 +80,40 @@
# An example or 'retrying participant' :
#
# class RetryParticipant
# include Ruote::LocalParticipant
#
- # def initialize (opts)
+ # def initialize(opts)
# @opts = opts
# end
#
- # def consume (workitem)
+ # def consume(workitem)
# begin
# do_the_job
# reply(workitem)
# rescue
# re_dispatch(workitem, :in => @opts['delay'] || '1s')
# end
# end
#
- # def cancel (fei, flavour)
+ # def cancel(fei, flavour)
# unschedule_re_dispatch(fei)
# end
# end
#
# Note how unschedule_re_dispatch is used in the cancel method. Warning,
# this example could loop forever...
#
- def unschedule_re_dispatch (fei)
+ def unschedule_re_dispatch(fei)
fexp = Ruote::Exp::FlowExpression.fetch(
@context, Ruote::FlowExpressionId.extract_h(fei))
if s = fexp.h['re_dispatch_sched_id']
@context.storage.delete_schedule(s)
end
end
- # WARNING : this method is only for 'stateless' participants, ie
- # participants that are registered in the engine by passing their class
- # and a set of options, like in
- #
- # engine.register_participant 'alpha', MyParticipant, 'info' => 'none'
- #
# This reject method replaces the workitem in the [internal] message queue
# of the ruote engine (since it's a local participant, it has access to
# the storage and it's thus easy).
# The idea is that another worker will pick up the workitem and
# do the participant dispatching.