I am starting a Supervisor that monitors two children. The second child needs a reference to the first. It seams like this should be possible because by using the one_for_rest strategy I can make sure that if the first dies the second is restarted.
children = [
supervisor(SupervisorA, [arg1]),
supervisor(SupervisorB, [arg2, ref_to_supervisor_a_process]),
]
supervise(children, strategy: :one_for_rest)
Ideally without having to globally name either process.
SupervisorA can supply the name: option to Supervisor.start_link/3.
SupervisorB can then use Process.whereis/1 to resolve the name to a pid or just send messages to the named process.
https://hexdocs.pm/elixir/Supervisor.html#start_link/3 https://hexdocs.pm/elixir/Process.html#whereis/1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With