[erlang-questions] Forwarding call from one gen_server to another

Paul Fisher pfisher@REDACTED
Tue Jun 17 20:33:40 CEST 2008


On Tue, 2008-06-17 at 19:34 +0200, Jeroen Koops wrote:
> I was wondering what the common way is to call one gen_server, have
> this call forwarded to another gen_server, and have this other server
> reply to the client. One way of doing this is by having the first
> gen_server send a cast to the second gen_server, including the PID of
> the client, and then respond with a noreply. The second gen_server
> handles the cast by explicitly responding to the client using
> gen_server:reply() - using the PID sent by the original gen_server, of
> course. This seems to work, but it feels like a clumsy way to do it -
> isn't there a better way?

That's the way to do it (although you'll need to pass along the whole
>From parameter, which is really a 2-arity tuple with the calling
processes pid and a make_ref/0 specific to that call.)


-- 
paul




More information about the erlang-questions mailing list