diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app_utils.erl | 22 | ||||
| -rw-r--r-- | src/rabbit_plugins.erl | 12 |
2 files changed, 31 insertions, 3 deletions
diff --git a/src/app_utils.erl b/src/app_utils.erl index e53909ddfc..eccf3d21e6 100644 --- a/src/app_utils.erl +++ b/src/app_utils.erl @@ -17,11 +17,13 @@ -export([load_applications/1, start_applications/1, start_applications/2, stop_applications/1, stop_applications/2, app_dependency_order/2, - wait_for_applications/1, app_dependencies/1]). + wait_for_applications/1, app_dependencies/1, app_modules/1, + which_applications/0, update_running_apps/2]). -ifdef(use_specs). -type error_handler() :: fun((atom(), any()) -> 'ok'). +-type diff() :: [atom()]. -spec load_applications([atom()]) -> 'ok'. -spec start_applications([atom()]) -> 'ok'. @@ -31,12 +33,30 @@ -spec wait_for_applications([atom()]) -> 'ok'. -spec app_dependency_order([atom()], boolean()) -> [digraph:vertex()]. -spec app_dependencies(atom()) -> [atom()]. +-spec update_running_apps(fun (() -> 'ok'), + fun ((diff()) -> 'ok')) -> 'ok'. +-spec which_applications() -> [atom()]. +-spec app_modules(atom()) -> [module()]. -endif. %%--------------------------------------------------------------------------- %% Public API +update_running_apps(MakeChanges, WithChanges) -> + Old = sets:from_list(which_applications()), + MakeChanges(), + New = sets:from_list(which_applications()), + Diff = sets:to_list(sets:subtract(New, Old)), + WithChanges(Diff). + +which_applications() -> + [App || {App, _, _} <- rabbit_misc:which_applications()]. + +app_modules(App) -> + {ok, Modules} = application:get_key(App, modules), + Modules. + load_applications(Apps) -> load_applications(queue:from_list(Apps), sets:new()), ok. diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 1799570d15..add818e375 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -40,10 +40,18 @@ enable(Enabled) -> prepare_plugins(Enabled), - rabbit_boot:start(Enabled). + app_utils:update_running_apps( + fun() -> rabbit_boot:start(Enabled) end, + fun(Diff) -> + ok = rabbit_event:notify(plugins_changed, [{enabled, Diff}]) + end). disable(Plugins) -> - rabbit_boot:stop(Plugins). + app_utils:update_running_apps( + fun() -> rabbit_boot:stop(Plugins) end, + fun(Diff) -> + ok = rabbit_event:notify(plugins_changed, [{disabled, Diff}]) + end). %% @doc Prepares the file system and installs all enabled plugins. setup() -> |
