The documentation details the following:
When the supervisor starts, it traverses all child specifications and then starts each child in the order they are defined. This is done by calling the function defined under the :start key in the child specification and typically defaults to start_link/1.
Consider a Supervisor that has two processes to start, from two specs.
These processes are not named.
When the first process is started, some value is generated:
@impl GenServer
def init(_arg) do
...
# Note that the value does not have to be in the state.
{:ok, some_value}
end
How can we pass this value as an argument to the second spec?
{SomeWorker, value_from_first_worker}
The first worker should expose some kind of API for the second worker to call.
Besides, since the second worker relies on the first, you may want to set the supervisor's
strategy: :rest_for_one
.