tres/message_handler: Fix to use DynamicSupervisor instead of :simple_one_for_one
This commit is contained in:
parent
6bba512271
commit
a316bf2416
6 changed files with 10 additions and 11 deletions
BIN
bin/enum_gen
BIN
bin/enum_gen
Binary file not shown.
|
|
@ -5,7 +5,7 @@ defmodule LeaderExample.Leader do
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
def start_link(datapath_id, args) do
|
def start_link([datapath_id, args]) do
|
||||||
:locks_leader.start_link(__MODULE__, [datapath_id, args], [])
|
:locks_leader.start_link(__MODULE__, [datapath_id, args], [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ defmodule LearningSwitch.Ofctl do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_link(datapath_id, args) do
|
def start_link([datapath_id, args]) do
|
||||||
GenServer.start_link(__MODULE__, [datapath_id, args])
|
GenServer.start_link(__MODULE__, [datapath_id, args])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ defmodule PatchPanel.Openflow.Controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_link({datapath_id, _aux_id}, _start_args) do
|
def start_link([{datapath_id, _aux_id}, _start_args]) do
|
||||||
GenServer.start_link(__MODULE__, [datapath_id])
|
GenServer.start_link(__MODULE__, [datapath_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ defmodule Tres.ExampleHandler do
|
||||||
conn_ref: nil
|
conn_ref: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_link(datapath, args) do
|
def start_link([datapath, args]) do
|
||||||
GenServer.start_link(__MODULE__, [datapath, args])
|
GenServer.start_link(__MODULE__, [datapath, args])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
defmodule Tres.MessageHandlerSup do
|
defmodule Tres.MessageHandlerSup do
|
||||||
use Supervisor
|
use DynamicSupervisor
|
||||||
|
|
||||||
def start_link(cb_mod) do
|
def start_link(cb_mod) do
|
||||||
Supervisor.start_link(__MODULE__, [cb_mod], name: __MODULE__)
|
DynamicSupervisor.start_link(__MODULE__, [cb_mod], name: __MODULE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
def init([cb_mod]) do
|
def init([_cb_mod]) do
|
||||||
children = [worker(cb_mod, [], restart: :temporary, shutdown: 5000)]
|
DynamicSupervisor.init(strategy: :one_for_one)
|
||||||
supervise(children, strategy: :simple_one_for_one)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_child({dpid, aux_id}) do
|
def start_child({dpid, aux_id}) do
|
||||||
{_cb_mod, cb_args} = Tres.Utils.get_callback_module()
|
{cb_mod, cb_args} = Tres.Utils.get_callback_module()
|
||||||
Supervisor.start_child(__MODULE__, [{dpid, aux_id}, cb_args])
|
DynamicSupervisor.start_child(__MODULE__, {cb_mod, [{dpid, aux_id}, cb_args]})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue