diff --git a/src/msp_channel_sup.erl b/src/msp_channel_sup.erl new file mode 100644 index 0000000..bbcf789 --- /dev/null +++ b/src/msp_channel_sup.erl @@ -0,0 +1,48 @@ +%%% @doc +%%% Minimal Stream Protocol : Channel Worker Supervisor +%%% @end + +-module(msp_channel_sup). +-vsn("0.1.0"). +-behaviour(supervisor). +-author("Jarvis Carroll "). +-copyright("Jarvis Carroll "). +-license("MIT"). + + +-export([start_channel/0]). +-export([start_link/0]). +-export([init/1]). + + +-spec start_channel() -> Result + when Result :: {ok, pid()} + | {error, Reason}, + Reason :: {already_started, pid()} + | {shutdown, term()} + | term(). + +start_channel() -> + supervisor:start_child(?MODULE, []). + + +-spec start_link() -> {ok, pid()}. + +start_link() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, none). + + +-spec init(none) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}. +%% @private +%% The OTP init/1 function. + +init(none) -> + RestartStrategy = {simple_one_for_one, 1, 60}, + Channel = + {msp_channel, + {msp_channel, start_link, []}, + temporary, + brutal_kill, + worker, + [msp_channel]}, + {ok, {RestartStrategy, [Channel]}}.