tres/message_handler: Fix to use DynamicSupervisor instead of :simple_one_for_one

This commit is contained in:
Eishun Kondoh 2018-05-02 16:22:31 +09:00
parent 6bba512271
commit a316bf2416
6 changed files with 10 additions and 11 deletions

Binary file not shown.

View file

@ -5,7 +5,7 @@ defmodule LeaderExample.Leader do
require Logger
def start_link(datapath_id, args) do
def start_link([datapath_id, args]) do
:locks_leader.start_link(__MODULE__, [datapath_id, args], [])
end

View file

@ -22,7 +22,7 @@ defmodule LearningSwitch.Ofctl do
]
end
def start_link(datapath_id, args) do
def start_link([datapath_id, args]) do
GenServer.start_link(__MODULE__, [datapath_id, args])
end

View file

@ -26,7 +26,7 @@ defmodule PatchPanel.Openflow.Controller do
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])
end

View file

@ -10,7 +10,7 @@ defmodule Tres.ExampleHandler do
conn_ref: nil
end
def start_link(datapath, args) do
def start_link([datapath, args]) do
GenServer.start_link(__MODULE__, [datapath, args])
end

View file

@ -1,17 +1,16 @@
defmodule Tres.MessageHandlerSup do
use Supervisor
use DynamicSupervisor
def start_link(cb_mod) do
Supervisor.start_link(__MODULE__, [cb_mod], name: __MODULE__)
DynamicSupervisor.start_link(__MODULE__, [cb_mod], name: __MODULE__)
end
def init([cb_mod]) do
children = [worker(cb_mod, [], restart: :temporary, shutdown: 5000)]
supervise(children, strategy: :simple_one_for_one)
def init([_cb_mod]) do
DynamicSupervisor.init(strategy: :one_for_one)
end
def start_child({dpid, aux_id}) do
{_cb_mod, cb_args} = Tres.Utils.get_callback_module()
Supervisor.start_child(__MODULE__, [{dpid, aux_id}, cb_args])
{cb_mod, cb_args} = Tres.Utils.get_callback_module()
DynamicSupervisor.start_child(__MODULE__, {cb_mod, [{dpid, aux_id}, cb_args]})
end
end