[erlang-questions] OTP application design

Vlad Dumitrescu <>
Tue Jun 12 12:26:41 CEST 2007


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



More information about the erlang-questions mailing list