I am trying to address this warning in my repo warning: :simple_one_for_one strategy is deprecated, please use DynamicSupervisor instead
I have updated all deps as recommended by some online solutions.
I have tried to migrate to using DynamicSupervisor but 3 problems:
i still see the warning
this does not do what i was doing initially whereby My.ChildProcess is started when application starts
instead of one supervisor now i had a supervisor that starts a dynamic supervisor that starts My.ChildProcess??? Why do i need to do this?
defmodule My.Application do
use Application
@impl true
def start(_type, _args) do
children = [
{DynamicSupervisor, strategy: :one_for_one, name: My.DynamicSupervisor}
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
defmodule My.DynamicSupervisor do
use DynamicSupervisor
def start_link(init_arg) do
DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
end
def start_child() do
spec = %{id: My.ChildProcess, start: {My.ChildProcess, :start_link, [[]]}}
DynamicSupervisor.start_child(__MODULE__, spec)
end
@impl true
def init(init_arg) do
DynamicSupervisor.init(
strategy: :one_for_one,
extra_arguments: [init_arg]
)
end
end