diff --git a/applications/acdc/src/acdc_queue_manager.erl b/applications/acdc/src/acdc_queue_manager.erl index 5e0c557dbf0..10d9e530af4 100644 --- a/applications/acdc/src/acdc_queue_manager.erl +++ b/applications/acdc/src/acdc_queue_manager.erl @@ -14,7 +14,7 @@ -behaviour(gen_listener). %% API --export([start_link/2, start_link/3 +-export([start_link/3 ,handle_member_call/2 ,handle_member_call_success/2 ,handle_member_call_cancel/2 @@ -118,18 +118,6 @@ %% @doc Starts the server. %% @end %%------------------------------------------------------------------------------ --spec start_link(pid(), kz_json:object()) -> kz_types:startlink_ret(). -start_link(Super, QueueJObj) -> - AccountId = kz_doc:account_id(QueueJObj), - QueueId = kz_doc:id(QueueJObj), - - gen_listener:start_link(?SERVER - ,[{'bindings', ?BINDINGS(AccountId, QueueId)} - ,{'responders', ?RESPONDERS} - ] - ,[Super, QueueJObj] - ). - -spec start_link(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(Super, AccountId, QueueId) -> gen_listener:start_link(?SERVER @@ -288,33 +276,17 @@ pick_winner(Srv, Resps) -> pick_winner(Srv, Resps, strategy(Srv), next_winner(Sr %% @end %%------------------------------------------------------------------------------ -spec init([pid() | kz_json:object() | kz_term:ne_binary()]) -> {'ok', mgr_state()}. -init([Super, QueueJObj]) -> - AccountId = kz_doc:account_id(QueueJObj), - QueueId = kz_doc:id(QueueJObj), - - kz_util:put_callid(<<"mgr_", QueueId/binary>>), - - init(Super, AccountId, QueueId, QueueJObj); - init([Super, AccountId, QueueId]) -> kz_util:put_callid(<<"mgr_", QueueId/binary>>), AcctDb = kz_util:format_account_id(AccountId, 'encoded'), {'ok', QueueJObj} = kz_datamgr:open_cache_doc(AcctDb, QueueId), - init(Super, AccountId, QueueId, QueueJObj). - -init(Super, AccountId, QueueId, QueueJObj) -> - process_flag('trap_exit', 'false'), - - AccountDb = kz_util:format_account_id(AccountId, 'encoded'), - _ = kz_datamgr:add_to_doc_cache(AccountDb, QueueId, QueueJObj), - _ = start_secondary_queue(AccountId, QueueId), gen_listener:cast(self(), {'start_workers'}), Strategy = get_strategy(kz_json:get_value(<<"strategy">>, QueueJObj)), - StrategyState = create_strategy_state(Strategy, AccountDb, QueueId), + StrategyState = create_strategy_state(Strategy, AcctDb, QueueId), _ = update_strategy_state(self(), Strategy, StrategyState), diff --git a/applications/acdc/src/acdc_queue_sup.erl b/applications/acdc/src/acdc_queue_sup.erl index 46b35880136..97a2ffa1e54 100644 --- a/applications/acdc/src/acdc_queue_sup.erl +++ b/applications/acdc/src/acdc_queue_sup.erl @@ -22,9 +22,9 @@ %% Supervisor callbacks -export([init/1]). --define(CHILDREN, [?SUPER('acdc_queue_workers_sup') - ,?WORKER_ARGS('acdc_queue_manager', [self() | Args]) - ]). +-define(CHILDREN(Args), [?SUPER('acdc_queue_workers_sup') + ,?WORKER_ARGS('acdc_queue_manager', [self() | Args]) + ]). %%%============================================================================= %%% api functions @@ -81,15 +81,15 @@ status(Supervisor) -> %% specifications. %% @end %%------------------------------------------------------------------------------ --spec init(list()) -> kz_types:sup_init_ret(). -init(Args) -> +-spec init([kz_term:ne_binary(),...]) -> kz_types:sup_init_ret(). +init([_AcctId, _QueueId]=Args) -> RestartStrategy = 'one_for_all', MaxRestarts = 2, MaxSecondsBetweenRestarts = 2, SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}, - {'ok', {SupFlags, ?CHILDREN}}. + {'ok', {SupFlags, ?CHILDREN(Args)}}. %%%============================================================================= %%% Internal functions