[erlang-questions] OTP application design

Kirill Zaborski <>
Tue Jun 12 17:37:33 CEST 2007


Thanks, quite reasonable.
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).

Regards,
Kirill.

On 6/12/07, Vlad Dumitrescu <> wrote:
>
> Hi,
>
> On 6/12/07, Kirill Zaborski <> wrote:
> > I'm trying to design some application but not sure how to do it properly
> in
> > terms of OTP design principles. What I'm trying to implement right now
> is a
> > configuration of a central "dispatcher" app and "worker" apps which will
> be
> > added and deleted dynamically (they will reside on hosts remote to the
> > dispatcher). Both types of applications are gen_server instances. With
> > dispatcher I can call its public API e.g. dispatcher:request(Data),
> which
> > will be  then translated to gen_server:call(?MODULE, {request, Data}).
> And
> > then I need to pass this request to worker applications based on some
> rules.
> > But I do not understand what should I do with worker apps, how should I
> call
> > them.
> > They register themself in dispatcher with dispatcher:connect(self()).
> But
> > then in dispatcher process I have their worker process Pid and so I can
> not
> > use gen_server API. Is there some way around this?
>
> Your workers can define an own API, where for example worker:work(Pid,
> Data) will translate to gen_server:call(Pid, {work, Data}).
>
> In the case of the dispatcher, you have registered the process with
> the module's name, so you could use ?MODULE as a reference to the
> server. For the workers, the pids work just as well.
>
> best regards,
> Vlad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070612/6ca5b0e0/attachment.html>


More information about the erlang-questions mailing list