19 lines
391 B
Elixir
19 lines
391 B
Elixir
defmodule Counter.DynamicSupervisor do
|
|
use DynamicSupervisor
|
|
|
|
def start_link(_) do
|
|
DynamicSupervisor.start_link(__MODULE__, nil)
|
|
end
|
|
|
|
def start_worker(name) do
|
|
DynamicSupervisor.start_child(
|
|
{:via, PartitionSupervisor, {Counter.DynamicSupervisors, self()}},
|
|
{Counter.Worker, name})
|
|
end
|
|
|
|
@impl true
|
|
def init(_) do
|
|
DynamicSupervisor.init(strategy: :one_for_one)
|
|
end
|
|
end
|