[erlang-questions] beginner: passing messages between supervisor trees
Ulf Wiger (TN/EAB)
Tue Mar 11 22:47:49 CET 2008
Pinku Surana skrev:
> I'm still new to the idea of supervisors in Erlang. Assume I have a
> client C managed by supervisor MC, and server S managed by supervisor
> MS. When C sends a message to S, does the message get routed through MC
> and MS first? Or do C and S communicate directly? If so, where in the
> code are they connected together?
The supervisor has nothing to do with messages going between
C and S. The only job of the supervisor is to monitor its
children, and perhaps restart them if they die.
> If C sends a message to S and S fails, will C's message be saved
> somewhere so it can try again after restarting S? Is this done
> automatically, or manually by one of the supervisors?
> If S fails repeatedly, then I want to replace it with S2 (a simpler
> task). How can C's messages be routed to S2 transparently? I don't
> want C to be aware of the failures.
If you want this sort of behaviour, you need some kind of buffering
process between C and S.
The supervisors in Erlang offer no facility for replacing S with
S2 after repeating failures. The main reason is that the arguments
used for (re-)starting S are the same each time, and S is given no
information about why it is restarting, or how many times it's
I did make an extended supervisor behaviour once (haven't mentioned
it since end of 2003, so if I'm harping on about it, it's at least
at a very low intensity.) It never caught on, so I guess most people
are perfectly happy with the existing supervisor module. (:
More information about the erlang-questions