Best way to reference multiple interdependent processes

Hello all,
I am working on a supervisor that will supervise three interdependent processes; say A, B and C. B depends on A and C depends on B. These processes will likely live and die together, so they will be restarted together. I will run multiple copies of such supervisor, each ow which will run its three sons.

I can easily start and supervise them, but my question is: what is the idiomatic way so that B knows about A and C knows about B? Should just I register them with a local name, so that supervisor{ā€œ123ā€} runs A{ā€œ123ā€}, B{ā€œ123ā€} and C{ā€œ123ā€}, and each of them looks up its sibilings by name? Or is there something clearer?

Supervisors are only about supervising children not for aiding the communication between children. So yes you want to use some strategy of registering processes to a registry.


Not sure if I am misreading but Iā€™d go for:

  1. Use a Registry with your own naming scheme, e.g. MyApp.XyzSupervisor.Instance123.WorkerA so you can always identify the A/B/C processes (so yes you are on the right path)
  2. Have a GenServer that accepts one message and then distributes work to the A/B/C workers
1 Like