[erlang-questions] Reinserting a message into a gen_server's mailbox

Ulf Wiger ulf.wiger@REDACTED
Wed Aug 11 11:29:24 CEST 2010


Hynek Vychodil wrote:
> I can't see any reason why this request arrived to this single
> gen_server at all. There is known anti-pattern in the linux kernel
> development named "midlayer mistake" and common advice is, if there is
> not a reason for midlayer use a library Luke. Translated to Erlang: if
> there is not a reason for process use a module Luke. I know it is
> strong temptation add some abstract layer and separate things and
> server is first thing what comes on mind in Erlang but stateless
> module often serves too.

I agree, and in my experience, this extra layer is often made
necessary by the simple fact that you cannot use complex terms
as locally registered names. Thus, you end up having to 'index'
the workers somehow.

Providing a generic solution to this was the main driving force
behind gproc (http://github.com/esl/gproc).

If a dispatching server ends up only looking at a request and
forwarding it to the right server, it may well be that the
processes doing the actual work could simply register themselves
appropriately in gproc and eliminate the dispatcher altogether.

BR,
Ulf W
-- 
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com


More information about the erlang-questions mailing list