[erlang-questions] Supervisor (ab)use

Schneider <>
Mon Sep 12 14:08:14 CEST 2016

Dear List,

I want to implement a service which starts and stops a bunch of 
endpoints. All endpoints are very similar in their basic behavior and 
are started with several predefined parameters such as controlling 
process, a guid etc. with the endpoint id added at the end of the 
argument list. The simple one for one supervisor matches these 
requirements perfectly.
Well, actually there are two types of endpoints, readers and writers.

I use a simple one for one supervisor and add a child using:

supervisor:start_child(Sup, [Entity_id, Type])

The supervisor is defined as::

init([NNS]) ->
     {ok, { {simple_one_for_one, 1, 5},
              {rtps_endpoint, start_link, [NNS]},
              transient, 5000, worker, [rtps_endpoint]}]
          } }.

rtps_endpoint reads:

start_link(NS, Entity_id, reader) ->
     start_link(NS, Entity_id, rtps_reader);
start_link(NS, Entity_id, writer) ->
     start_link(NS, Entity_id, rtps_writer);
start_link(NS, Entity_id, Module) ->
     gen_server:start_link({via, rtps_participant, {NS, Entity_id}}, 
Module, [Entity_id], []).

This seems to work fine, but I am wondering if there are potential 
issues with this construct, especially with the Modules in the child 
specifications and code replacement.

Any advice?

- Frans

More information about the erlang-questions mailing list