Skip to content

Commit

Permalink
KAZOO=543: update manager's moh field when queue is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
James Aimonetti committed Mar 3, 2013
1 parent 300af3c commit b550b35
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 65 deletions.
2 changes: 1 addition & 1 deletion whistle_apps/apps/acdc/src/acdc_queue_fsm.erl
Expand Up @@ -641,7 +641,7 @@ connecting('current_call', _, #state{member_call=Call
%%--------------------------------------------------------------------
handle_event({'refresh', QueueJObj}, StateName, State) ->
lager:debug("refreshing queue configs"),
{'next_state', StateName, update_properties(QueueJObj, State)};
{'next_state', StateName, update_properties(QueueJObj, State), 'hibernate'};
handle_event(_Event, StateName, State) ->
lager:debug("unhandled event in state ~s: ~p", [StateName, _Event]),
{'next_state', StateName, State}.
Expand Down
4 changes: 3 additions & 1 deletion whistle_apps/apps/acdc/src/acdc_queue_handler.erl
Expand Up @@ -79,7 +79,9 @@ handle_queue_change(AccountDb, AccountId, QueueId, <<"doc_edited">>) ->
WorkersSup = acdc_queue_sup:workers_sup(QueueSup),
[acdc_queue_fsm:refresh(acdc_queue_worker_sup:fsm(WorkerSup), JObj)
|| WorkerSup <- acdc_queue_workers_sup:workers(WorkersSup)
]
],
Mgr = acdc_queue_sup:manager(QueueSup),
acdc_queue_manager:refresh(Mgr, JObj)
end;
handle_queue_change(_, AccountId, QueueId, <<"doc_deleted">>) ->
lager:debug("maybe stopping existing queue for ~s: ~s", [AccountId, QueueId]),
Expand Down
15 changes: 13 additions & 2 deletions whistle_apps/apps/acdc/src/acdc_queue_manager.erl
Expand Up @@ -21,6 +21,7 @@
,handle_config_change/2
,should_ignore_member_call/3
,config/1
,refresh/2
]).

%% FSM helpers
Expand Down Expand Up @@ -201,6 +202,8 @@ should_ignore_member_call(Srv, Call, CallJObj) ->

config(Srv) -> gen_listener:call(Srv, 'config').

refresh(Mgr, QueueJObj) -> gen_listener:cast(Mgr, {'refresh', QueueJObj}).

strategy(Srv) -> gen_listener:call(Srv, 'strategy').
next_winner(Srv) -> gen_listener:call(Srv, 'next_winner').

Expand Down Expand Up @@ -440,6 +443,10 @@ handle_cast({'gen_listener', {'created_queue', _}}, State) ->
handle_cast({'gen_listener', {'is_consuming', _}}, State) ->
{'noreply', State};

handle_cast({'refresh', QueueJObj}, State) ->
lager:debug("refreshing queue configs"),
{'noreply', update_properties(QueueJObj, State), 'hibernate'};

handle_cast(_Msg, State) ->
lager:debug("unhandled cast: ~p", [_Msg]),
{'noreply', State}.
Expand Down Expand Up @@ -675,5 +682,9 @@ maybe_start_queue_workers(QueueSup, AgentCount) ->
N when N >= AgentCount -> 'ok';
N when N < AgentCount -> gen_listener:cast(self(), {start_worker, AgentCount-N})
end.



update_properties(QueueJObj, State) ->
State#state{
enter_when_empty=wh_json:is_true(<<"enter_when_empty">>, QueueJObj, 'true')
,moh=wh_json:get_value(<<"moh">>, QueueJObj)
}.
61 changes: 0 additions & 61 deletions whistle_apps/apps/callflow/src/module/cf_queue.erl

This file was deleted.

0 comments on commit b550b35

Please sign in to comment.