Thanks, quite reasonable.<br>But implementing an emulator for worker seems a bit ugly - I won't be able use "normal" behavior so I will need gen_server with handle_call({work,Data}) (taken from your example).
<br><br>Regards,<br>Kirill.<br><br><div><span class="gmail_quote">On 6/12/07, <b class="gmail_sendername">Vlad Dumitrescu</b> <<a href="mailto:vladdu55@gmail.com">vladdu55@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>On 6/12/07, Kirill Zaborski <<a href="mailto:qrilka@gmail.com">qrilka@gmail.com</a>> wrote:<br>> I'm trying to design some application but not sure how to do it properly in<br>> terms of OTP design principles. What I'm trying to implement right now is a
<br>> configuration of a central "dispatcher" app and "worker" apps which will be<br>> added and deleted dynamically (they will reside on hosts remote to the<br>> dispatcher). Both types of applications are gen_server instances. With
<br>> dispatcher I can call its public API e.g. dispatcher:request(Data), which<br>> will be then translated to gen_server:call(?MODULE, {request, Data}). And<br>> then I need to pass this request to worker applications based on some rules.
<br>> But I do not understand what should I do with worker apps, how should I call<br>> them.<br>> They register themself in dispatcher with dispatcher:connect(self()). But<br>> then in dispatcher process I have their worker process Pid and so I can not
<br>> use gen_server API. Is there some way around this?<br><br>Your workers can define an own API, where for example worker:work(Pid,<br>Data) will translate to gen_server:call(Pid, {work, Data}).<br><br>In the case of the dispatcher, you have registered the process with
<br>the module's name, so you could use ?MODULE as a reference to the<br>server. For the workers, the pids work just as well.<br><br>best regards,<br>Vlad<br></blockquote></div><br>