%%%----------------------------------------------------------------------------- %%% @copyright (C) 2012-2019, 2600Hz %%% @doc %%% @author Luis Azedo %%% @end %%%----------------------------------------------------------------------------- -module(fax_worker_sup). -behaviour(supervisor). -include("fax.hrl"). -define(SERVER, ?MODULE). -export([start_fax_job/1]). -export([start_link/0]). -export([init/1]). -define(CHILDREN, [?WORKER_TYPE('fax_worker', 'transient')]). -spec start_fax_job(fax_job()) -> any(). start_fax_job(FaxJob) -> supervisor:start_child(?MODULE, [FaxJob]). %%------------------------------------------------------------------------------ %% @doc Starts the supervisor. %% @end %%------------------------------------------------------------------------------ -spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). %%------------------------------------------------------------------------------ %% @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. %% @end %%------------------------------------------------------------------------------ -spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, MaxSecondsBetweenRestarts = 5, SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}, {'ok', {SupFlags, ?CHILDREN}}.