22 lines
507 B
Elixir
22 lines
507 B
Elixir
defmodule Manager do
|
|
use DynamicSupervisor
|
|
|
|
def start_link(init_arg) do
|
|
DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
|
|
end
|
|
|
|
@impl true
|
|
def init(_init_arg) do
|
|
DynamicSupervisor.init(strategy: :one_for_one)
|
|
end
|
|
|
|
def create_broker(protocol, port, to_host, to_port) do
|
|
spec = {Broker, {protocol, port, to_host, to_port}}
|
|
DynamicSupervisor.start_child(__MODULE__, spec)
|
|
end
|
|
|
|
def list_brokers() do
|
|
DynamicSupervisor.which_children(__MODULE__)
|
|
end
|
|
end
|