summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Watson <tim@rabbitmq.com>2012-05-28 13:41:57 +0100
committerTim Watson <tim@rabbitmq.com>2012-05-28 13:41:57 +0100
commitdacdf4e3616d49f3091c1f2831ca38cb64452d79 (patch)
tree7e59410a28eedac5504e3b6d11b3a427d3084e9f
parent9bc2c057e586e917264a696e18ce6f0c11ef27e1 (diff)
downloadrabbitmq-server-dacdf4e3616d49f3091c1f2831ca38cb64452d79.tar.gz
rename rabbit_plugins API calls to be less verbose
-rw-r--r--src/rabbit.erl6
-rw-r--r--src/rabbit_plugins.erl34
-rw-r--r--src/rabbit_plugins_main.erl24
3 files changed, 32 insertions, 32 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 1dff4d53..8a25d9ff 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -302,13 +302,13 @@ start() ->
start_it(fun() ->
ok = prepare(),
ok = app_utils:start_applications(app_startup_order()),
- ok = print_plugin_info(rabbit_plugins:active_plugins())
+ ok = print_plugin_info(rabbit_plugins:active())
end).
boot() ->
start_it(fun() ->
ok = prepare(),
- Plugins = rabbit_plugins:prepare_plugins(),
+ Plugins = rabbit_plugins:setup(),
ToBeLoaded = Plugins ++ ?APPS,
ok = app_utils:load_applications(ToBeLoaded),
StartupApps = app_utils:app_dependency_order(ToBeLoaded, false),
@@ -421,7 +421,7 @@ app_startup_order() ->
app_utils:app_dependency_order(?APPS, false).
app_shutdown_order() ->
- Apps = ?APPS ++ rabbit_plugins:active_plugins(),
+ Apps = ?APPS ++ rabbit_plugins:active(),
app_utils:app_dependency_order(Apps, true).
%%---------------------------------------------------------------------------
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index 84f559b9..7cf6eea9 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -17,8 +17,8 @@
-module(rabbit_plugins).
-include("rabbit.hrl").
--export([prepare_plugins/0, active_plugins/0, read_enabled_plugins/1,
- find_plugins/1, calculate_plugin_dependencies/3]).
+-export([setup/0, active/0, read_enabled/1,
+ list/1, dependencies/3]).
-define(VERBOSE_DEF, {?VERBOSE_OPT, flag}).
-define(MINIMAL_DEF, {?MINIMAL_OPT, flag}).
@@ -36,11 +36,11 @@
-ifdef(use_specs).
--spec(prepare_plugins/0 :: () -> [atom()]).
--spec(active_plugins/0 :: () -> [atom()]).
--spec(find_plugins/1 :: (string()) -> [#plugin{}]).
--spec(read_enabled_plugins/1 :: (file:filename()) -> [atom()]).
--spec(calculate_plugin_dependencies/3 ::
+-spec(setup/0 :: () -> [atom()]).
+-spec(active/0 :: () -> [atom()]).
+-spec(list/1 :: (string()) -> [#plugin{}]).
+-spec(read_enabled/1 :: (file:filename()) -> [atom()]).
+-spec(dependencies/3 ::
(boolean(), [atom()], [#plugin{}]) -> [atom()]).
-endif.
@@ -50,7 +50,7 @@
%%
%% @doc Prepares the file system and installs all enabled plugins.
%%
-prepare_plugins() ->
+setup() ->
{ok, PluginDir} = application:get_env(rabbit, plugins_dir),
{ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
{ok, EnabledPluginsFile} = application:get_env(rabbit,
@@ -60,14 +60,14 @@ prepare_plugins() ->
PluginName <- filelib:wildcard(ExpandDir ++ "/*/ebin/*.app")].
%% @doc Lists the plugins which are currently running.
-active_plugins() ->
+active() ->
{ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
- InstalledPlugins = [ P#plugin.name || P <- find_plugins(ExpandDir) ],
+ InstalledPlugins = [ P#plugin.name || P <- list(ExpandDir) ],
[App || {App, _, _} <- application:which_applications(),
lists:member(App, InstalledPlugins)].
%% @doc Get the list of plugins which are ready to be enabled.
-find_plugins(PluginsDir) ->
+list(PluginsDir) ->
EZs = [{ez, EZ} || EZ <- filelib:wildcard("*.ez", PluginsDir)],
FreeApps = [{app, App} ||
App <- filelib:wildcard("*/ebin/*.app", PluginsDir)],
@@ -87,7 +87,7 @@ find_plugins(PluginsDir) ->
Plugins.
%% @doc Read the list of enabled plugins from the supplied term file.
-read_enabled_plugins(PluginsFile) ->
+read_enabled(PluginsFile) ->
case rabbit_file:read_term_file(PluginsFile) of
{ok, [Plugins]} -> Plugins;
{ok, []} -> [];
@@ -103,7 +103,7 @@ read_enabled_plugins(PluginsFile) ->
%% When Reverse =:= true the bottom/leaf level applications are returned in
%% the resulting list, otherwise they're skipped.
%%
-calculate_plugin_dependencies(Reverse, Sources, AllPlugins) ->
+dependencies(Reverse, Sources, AllPlugins) ->
{ok, G} = rabbit_misc:build_acyclic_graph(
fun (App, _Deps) -> [{App, App}] end,
fun (App, Deps) -> [{App, Dep} || Dep <- Deps] end,
@@ -119,9 +119,9 @@ calculate_plugin_dependencies(Reverse, Sources, AllPlugins) ->
%%----------------------------------------------------------------------------
prepare_plugins(EnabledPluginsFile, PluginsDistDir, DestDir) ->
- AllPlugins = find_plugins(PluginsDistDir),
- Enabled = read_enabled_plugins(EnabledPluginsFile),
- ToUnpack = calculate_plugin_dependencies(false, Enabled, AllPlugins),
+ AllPlugins = list(PluginsDistDir),
+ Enabled = read_enabled(EnabledPluginsFile),
+ ToUnpack = dependencies(false, Enabled, AllPlugins),
ToUnpackPlugins = lookup_plugins(ToUnpack, AllPlugins),
Missing = Enabled -- plugin_names(ToUnpackPlugins),
@@ -251,4 +251,4 @@ plugin_names(Plugins) ->
%% Find plugins by name in a list of plugins.
lookup_plugins(Names, AllPlugins) ->
- [P || P = #plugin{name = Name} <- AllPlugins, lists:member(Name, Names)]. \ No newline at end of file
+ [P || P = #plugin{name = Name} <- AllPlugins, lists:member(Name, Names)].
diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl
index 7a81f0dd..dbca391c 100644
--- a/src/rabbit_plugins_main.erl
+++ b/src/rabbit_plugins_main.erl
@@ -102,9 +102,9 @@ action(enable, ToEnable0, _Opts, PluginsFile, PluginsDir) ->
[] -> throw({error_string, "Not enough arguments for 'enable'"});
_ -> ok
end,
- AllPlugins = rabbit_plugins:find_plugins(PluginsDir),
- Enabled = rabbit_plugins:read_enabled_plugins(PluginsFile),
- ImplicitlyEnabled = rabbit_plugins:calculate_plugin_dependencies(false, Enabled, AllPlugins),
+ AllPlugins = rabbit_plugins:list(PluginsDir),
+ Enabled = rabbit_plugins:read_enabled(PluginsFile),
+ ImplicitlyEnabled = rabbit_plugins:dependencies(false, Enabled, AllPlugins),
ToEnable = [list_to_atom(Name) || Name <- ToEnable0],
Missing = ToEnable -- plugin_names(AllPlugins),
case Missing of
@@ -115,7 +115,7 @@ action(enable, ToEnable0, _Opts, PluginsFile, PluginsDir) ->
end,
NewEnabled = lists:usort(Enabled ++ ToEnable),
write_enabled_plugins(PluginsFile, NewEnabled),
- NewImplicitlyEnabled = rabbit_plugins:calculate_plugin_dependencies(false, NewEnabled, AllPlugins),
+ NewImplicitlyEnabled = rabbit_plugins:dependencies(false, NewEnabled, AllPlugins),
maybe_warn_mochiweb(NewImplicitlyEnabled),
case NewEnabled -- ImplicitlyEnabled of
[] -> io:format("Plugin configuration unchanged.~n");
@@ -130,22 +130,22 @@ action(disable, ToDisable0, _Opts, PluginsFile, PluginsDir) ->
_ -> ok
end,
ToDisable = [list_to_atom(Name) || Name <- ToDisable0],
- Enabled = rabbit_plugins:read_enabled_plugins(PluginsFile),
- AllPlugins = rabbit_plugins:find_plugins(PluginsDir),
+ Enabled = rabbit_plugins:read_enabled(PluginsFile),
+ AllPlugins = rabbit_plugins:list(PluginsDir),
Missing = ToDisable -- plugin_names(AllPlugins),
case Missing of
[] -> ok;
_ -> print_list("Warning: the following plugins could not be found:",
Missing)
end,
- ToDisableDeps = rabbit_plugins:calculate_plugin_dependencies(true, ToDisable, AllPlugins),
+ ToDisableDeps = rabbit_plugins:dependencies(true, ToDisable, AllPlugins),
NewEnabled = Enabled -- ToDisableDeps,
case length(Enabled) =:= length(NewEnabled) of
true -> io:format("Plugin configuration unchanged.~n");
false -> ImplicitlyEnabled =
- rabbit_plugins:calculate_plugin_dependencies(false, Enabled, AllPlugins),
+ rabbit_plugins:dependencies(false, Enabled, AllPlugins),
NewImplicitlyEnabled =
- rabbit_plugins:calculate_plugin_dependencies(false, NewEnabled, AllPlugins),
+ rabbit_plugins:dependencies(false, NewEnabled, AllPlugins),
print_list("The following plugins have been disabled:",
ImplicitlyEnabled -- NewImplicitlyEnabled),
write_enabled_plugins(PluginsFile, NewEnabled),
@@ -175,10 +175,10 @@ format_plugins(Pattern, Opts, PluginsFile, PluginsDir) ->
OnlyEnabled = proplists:get_bool(?ENABLED_OPT, Opts),
OnlyEnabledAll = proplists:get_bool(?ENABLED_ALL_OPT, Opts),
- AvailablePlugins = rabbit_plugins:find_plugins(PluginsDir),
- EnabledExplicitly = rabbit_plugins:read_enabled_plugins(PluginsFile),
+ AvailablePlugins = rabbit_plugins:list(PluginsDir),
+ EnabledExplicitly = rabbit_plugins:read_enabled(PluginsFile),
EnabledImplicitly =
- rabbit_plugins:calculate_plugin_dependencies(false, EnabledExplicitly, AvailablePlugins) --
+ rabbit_plugins:dependencies(false, EnabledExplicitly, AvailablePlugins) --
EnabledExplicitly,
{ok, RE} = re:compile(Pattern),
Plugins = [ Plugin ||