Thanks that clear's up a lot!

On Dec 16, 2:18 pm, John Mettraux <[email protected]> wrote:
> On Thu, Dec 16, 2010 at 05:57:16AM -0800, rebo wrote:
>
> > Can someone clarify whether my understanding of the Worker and Engine
> > is correct.  Particularly with respect to the case of having a
> > separate worker process, from the main engine controls.
>
> Hello Rebo,
>
> welcome to the ruote mailing list.
>
> > Does the separate worker process 'know' what workitems to carry out
> > because the engine writes & dispatches this information to the
> > storage?
>
> Yes, exactly.
>
> > The worker is then monitoring the storage for this information?
>
> Yes, the workers grabs messages and execute actions according to them.
>
> > What code does the worker actually execute, compared to the process
> > that controls the engine? For instance within my rails ruote
> > initializer, i am defining storage_participants in a block that doesnt
> > get run if it is initialized by a rake task. As set out by ruote-kit:
>
> > unless $RAKE_TASK # don't register participants or set up AMQP in rake
> > tasks
>
> >    ... set up participants here.
>
> > end
>
> > So I take it the worker does not 'know' about participant definitions,
>
> Participant registration information is placed in the storage.
>
> Usually the convention is to register via the engine. The workers then just 
> fetch the participant list from the storage.
>
> The "unless $RAKE_TASK" that you are seeing is meant to prevent an 
> unnecessary re-registration. Re-registration is usually not a problem.
>
> > in which case which process executes custom local participants?
>
> The worker process does.
>
> Your engine and your worker are supposed to have access to the code/class of 
> your participants.
>
> > I have read the various pages on the ruote site and browsed the source
> > a bit but am still a little confused about how it all works.
>
> > I'm having to use a separate worker process because when running tests
> > with ruote as a single process the test-process dies after completion
> > and kills the threads spawned by ruote. This leaves the storage in a
> > fragile / sometimes broken state.
>
> Why don't you purge the storage before each new test ?
>
> For the ruote functional tests, I tend to do it after though :
>
>  https://github.com/jmettraux/ruote/blob/ruote2.1/test/functional/base...
>
> > It would be really useful to have a diagram of the basic program flow,
> > when running a separate worker process.
>
> There is a tiny diagram in
>
>  http://jmettraux.wordpress.com/2009/12/31/ruote-2-1-released/
>
> but it's not a flow diagram. Maybe it helps.
>
> This is outdated :
>
>  http://jmettraux.wordpress.com/2008/09/07/how-does-ruote-work/
>
> I won't do a diagram, but maybe some pseudo-code could help :
>
> ---8<---
> class Worker
>   def run
>     loop do
>       pick message
>       if message.action == 'launch'
>         create expression from message.tree
>         put apply message
>       elsif message.action == 'reply'
>         get expression from storage
>         expression.apply
>       elsif message.action == 'cancel'
>         get expression from storage
>         expession.cancel
>       end
>     end
>   end
> end
>
> class Engine
>   def launch (pdef)
>     put launch message
>   end
>   def cancel (wfid)
>     put cancel message
>   end
>   def processes
>     get expressions from storage
>     display expressions ordered by wfid (process instance)
>   end
> end
>
> class ParticipantExpression
>   def apply
>     push workitem to participant
>   end
>   def reply
>     put reply message
>   end
> end
> --->8---
>
> The basic program flow is the same. There is no difference between running a 
> worker within the engine or externally to it.
>
> In fact the Engine should better be renamed to Dashboard so that everybody 
> understands that the Engine is the system as large (dashboards + workers). 
> Sorry for the confusion but I was/am not smart enough to get it right the 
> first time.
>
> I hope this helps, questions are welcome, best regards.
>
> --
> John Mettraux -http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to