%% Copyright (c) 2026 Benoit Chesneau. Licensed under the MIT License.
%% See the LICENSE file at the project root.
%%
-module(erllama_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_one, intensity => 5, period => 30},
Children = [
sup_child(erllama_cache_sup),
worker_child(erllama_registry),
worker_child(erllama_inflight),
sup_child(erllama_model_sup),
worker_child(erllama_scheduler)
],
{ok, {SupFlags, Children}}.
sup_child(Mod) ->
#{
id => Mod,
start => {Mod, start_link, []},
restart => permanent,
shutdown => 5000,
type => supervisor,
modules => [Mod]
}.
worker_child(Mod) ->
#{
id => Mod,
start => {Mod, start_link, []},
restart => permanent,
shutdown => 5000,
type => worker,
modules => [Mod]
}.