blob: fc108808d62c44c6a0baec8056d2fb3ddc7c47f0 [file] [log] [blame]
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
% the License.
subscribe() ->
config:listen_for_changes(?MODULE, nil).
handle_config_change("ioq", _Key, _Val, _Persist, St) ->
ok = notify_ioq_pids(),
{ok, St};
handle_config_change("ioq2", _Key, _Val, _Persist, St) ->
ok = notify_ioq_pids(),
{ok, St};
handle_config_change("ioq2."++_Type, _Key, _Val, _Persist, St) ->
ok = notify_ioq_pids(),
{ok, St};
handle_config_change(_Sec, _Key, _Val, _Persist, St) ->
{ok, St}.
handle_config_terminate(_, stop, _) -> ok;
handle_config_terminate(_, _, _) ->
% We may have missed a change in the last five seconds
gen_server:cast(ioq_server, update_config),
spawn(fun() ->
config:listen_for_changes(?MODULE, nil)
notify_ioq_pids() ->
ok = lists:foreach(fun(Pid) ->
gen_server:cast(Pid, update_config)
end, ioq_sup:get_ioq2_servers()).