[erlang-questions] Supervisor child type

Fred Hebert mononcqc@REDACTED
Tue Sep 16 14:48:35 CEST 2014


On 09/16, Roger Lipscombe wrote:
> A child specification has a type, which tells whether the child is a
> supervisor or a worker. What is this actually used for? What's
> stopping me from putting 'worker' in the child spec, but actually
> calling supervisor:start_link? Or vice-versa?

The value is used by the OTP code when traversing supervision trees to
suspend/reload modules and do the proper calls to 'code change'.

It more or less lets you annotate the supervision tree with the metadata
required to do things in one swoop: is this a supervisor, is this a
worker, and if it's a worker, what kind of code is it running (a module
list or is it 'dynamic'?)

You can put wrong data in there if you want to. Nothing will stop you.
That sounds like a bad idea, but elans of civil disobedience can always
be applauded if done for the right reasons. Finding such a right reason
might be tricky in the current context, however.

"Sticking it to the release handler" might have a good ring to it, but
it would only be an obstruction to a middleman, shooting the messenger
if you will.

Much more efficient would be to confuse the maintainer or operator
directly, which most developers already do by virtue of poor or plainly
erroneous documentation; at least, in such a case, you can always yell a
vindictive "UGH JUST READ THE SOURCE!!!" down a google or skype session
(or if in the 90s, a phone), and get a similar effect.

Regards,
Fred.



More information about the erlang-questions mailing list