49 lines
1.1 KiB
Erlang
49 lines
1.1 KiB
Erlang
%%% @doc
|
|
%%% Minimal Stream Protocol : Channel Worker Supervisor
|
|
%%% @end
|
|
|
|
-module(msp_channel_sup).
|
|
-vsn("0.1.0").
|
|
-behaviour(supervisor).
|
|
-author("Jarvis Carroll <spiveehere@gmail.com>").
|
|
-copyright("Jarvis Carroll <spiveehere@gmail.com>").
|
|
-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]}}.
|