65 lines
2.2 KiB
Erlang
65 lines
2.2 KiB
Erlang
%%%-------------------------------------------------------------------
|
|
%%% @author anlicheng
|
|
%%% @copyright (C) 2026, <COMPANY>
|
|
%%% @doc
|
|
%%%
|
|
%%% @end
|
|
%%% Created : 13. 2月 2026 18:00
|
|
%%%-------------------------------------------------------------------
|
|
-module(sdlan_quic_channel_sup).
|
|
-author("anlicheng").
|
|
|
|
-behaviour(supervisor).
|
|
|
|
%% API
|
|
-export([start_link/0]).
|
|
-export([start_channel/2]).
|
|
|
|
%% Supervisor callbacks
|
|
-export([init/1]).
|
|
|
|
-define(SERVER, ?MODULE).
|
|
|
|
%%%===================================================================
|
|
%%% API functions
|
|
%%%===================================================================
|
|
|
|
%% @doc Starts the supervisor
|
|
-spec(start_link() -> {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
|
|
start_link() ->
|
|
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
|
|
|
|
%%%===================================================================
|
|
%%% Supervisor callbacks
|
|
%%%===================================================================
|
|
|
|
%% @private
|
|
%% @doc Whenever a supervisor is started using supervisor:start_link/[2,3],
|
|
%% this function is called by the new process to find out about
|
|
%% restart strategy, maximum restart frequency and child
|
|
%% specifications.
|
|
-spec(init(Args :: term()) ->
|
|
{ok, {SupFlags :: {RestartStrategy :: supervisor:strategy(),
|
|
MaxR :: non_neg_integer(), MaxT :: non_neg_integer()},
|
|
[ChildSpec :: supervisor:child_spec()]}}
|
|
| ignore | {error, Reason :: term()}).
|
|
init([]) ->
|
|
SupFlags = #{strategy => simple_one_for_one, intensity => 0, period => 1},
|
|
|
|
AChild = #{
|
|
id => sdlan_quic_channel,
|
|
start => {'sdlan_quic_channel', start_link, []},
|
|
restart => temporary,
|
|
shutdown => 2000,
|
|
type => worker,
|
|
modules => ['sdlan_quic_channel']
|
|
},
|
|
{ok, {SupFlags, [AChild]}}.
|
|
|
|
%%%===================================================================
|
|
%%% Internal functions
|
|
%%%===================================================================
|
|
|
|
-spec start_channel(NConn :: quicer:connection_handle(), Limits :: proplists:proplist()) -> supervisor:startchild_ret().
|
|
start_channel(NConn, Limits) when is_list(Limits) ->
|
|
supervisor:start_child(?MODULE, [NConn, Limits]). |