-module(opcua_server_session_sup).

-behaviour(supervisor).


%%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% API functions
-export([start_link/0]).

%% Behaviour supervisor callback functions
-export([init/1]).


  MACROS % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

-define(SERVER, ?MODULE).


%%% API FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).


  BEHAVIOUR supervisor  FUNCTIONS % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

init([]) ->
    SupFlags = #{strategy => one_for_all, intensity => 0, period => 1},
    SessionManagerSpec = #{
        id => opcua_server_session_manager,
        start => {opcua_server_session_manager, start_link, [#{}]}
    },
    SessionSupSpec = #{
        id => opcua_server_session_pool_sup,
        type => supervisor,
        start => {opcua_server_session_pool_sup, start_link, []}
    },
    {ok, {SupFlags, [SessionManagerSpec, SessionSupSpec]}}.

 EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 API functions
 Behaviour supervisor callback functions
 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 API FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
-module(opcua_server_session_sup).

-behaviour(supervisor).



-export([start_link/0]).

-export([init/1]).



-define(SERVER, ?MODULE).



start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).



init([]) ->
    SupFlags = #{strategy => one_for_all, intensity => 0, period => 1},
    SessionManagerSpec = #{
        id => opcua_server_session_manager,
        start => {opcua_server_session_manager, start_link, [#{}]}
    },
    SessionSupSpec = #{
        id => opcua_server_session_pool_sup,
        type => supervisor,
        start => {opcua_server_session_pool_sup, start_link, []}
    },
    {ok, {SupFlags, [SessionManagerSpec, SessionSupSpec]}}.
