lecture 05
This commit is contained in:
19 files changed
+439
No files matched your search
@@ -0,0 +1,18 @@
|
||||
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
|
||||
Reference in new issue
Block a user