diff options
| author | Tim Watson <watson.timothy@gmail.com> | 2014-01-12 15:10:59 +0000 |
|---|---|---|
| committer | Tim Watson <watson.timothy@gmail.com> | 2014-01-12 15:10:59 +0000 |
| commit | a5042edb4caa3383f5460f34b535d83ca50e5e20 (patch) | |
| tree | e9bf59860a2a5bf7d03e435841b6c79a513088c8 /src | |
| parent | a52d9b5eef47ac86551f48640b641ea6cbc68b64 (diff) | |
| download | rabbitmq-server-git-a5042edb4caa3383f5460f34b535d83ca50e5e20.tar.gz | |
Refactor - remove unused functions/comments/todos
Diffstat (limited to 'src')
| -rw-r--r-- | src/app_utils.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_boot.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_misc.erl | 41 | ||||
| -rw-r--r-- | src/rabbit_plugins.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_plugins_main.erl | 4 |
5 files changed, 14 insertions, 40 deletions
diff --git a/src/app_utils.erl b/src/app_utils.erl index 4622f6e0a8..5eeb692425 100644 --- a/src/app_utils.erl +++ b/src/app_utils.erl @@ -17,7 +17,7 @@ -export([load_applications/1, start_applications/1, start_applications/2, stop_applications/1, stop_applications/2, app_dependency_order/2, - running_applications/0, wait_for_applications/1, app_dependencies/1]). + wait_for_applications/1, app_dependencies/1]). -ifdef(use_specs). @@ -37,9 +37,6 @@ %%--------------------------------------------------------------------------- %% Public API -running_applications() -> - [App || {App, _, _} <- application:which_applications()]. - load_applications(Apps) -> load_applications(queue:from_list(Apps), sets:new()), ok. diff --git a/src/rabbit_boot.erl b/src/rabbit_boot.erl index 12a0116168..9ccad90334 100644 --- a/src/rabbit_boot.erl +++ b/src/rabbit_boot.erl @@ -163,7 +163,7 @@ run_boot_steps() -> ok. load_steps(Type) -> - StepAttrs = rabbit_misc:all_app_module_attributes(rabbit_boot_step), + StepAttrs = rabbit_misc:all_module_attributes_with_app(rabbit_boot_step), sort_boot_steps( Type, lists:usort( diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 59d6401f7c..4bfd0da37c 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -51,8 +51,8 @@ -export([dict_cons/3, orddict_cons/3, gb_trees_cons/3]). -export([gb_trees_fold/3, gb_trees_foreach/2]). -export([parse_arguments/3]). --export([all_app_module_attributes/1]). --export([all_module_attributes/1, build_graph/3, build_acyclic_graph/3]). +-export([all_module_attributes_with_app/1]). +-export([all_module_attributes/1, build_acyclic_graph/3]). -export([now_ms/0]). -export([const_ok/0, const/1]). -export([ntoa/1, ntoab/1]). @@ -92,12 +92,8 @@ :: rabbit_types:channel_exit() | rabbit_types:connection_exit()). -type(digraph_label() :: term()). -type(graph_vertex_fun() :: - fun (() -> [{digraph:vertex(), digraph_label()}])). --type(acyclic_graph_vertex_fun() :: fun ((atom(), [term()]) -> [{digraph:vertex(), digraph_label()}])). -type(graph_edge_fun() :: - fun (() -> [{digraph:vertex(), digraph:vertex()}])). --type(acyclic_graph_edge_fun() :: fun ((atom(), [term()]) -> [{digraph:vertex(), digraph:vertex()}])). -spec(method_record_type/1 :: (rabbit_framing:amqp_method_record()) @@ -215,17 +211,10 @@ -> {'ok', {atom(), [{string(), string()}], [string()]}} | 'no_command'). -spec(all_module_attributes/1 :: (atom()) -> [{atom(), [term()]}]). --spec(build_graph/3 :: - (graph_vertex_fun(), graph_edge_fun(), - [{atom(), [term()]}]) - -> rabbit_types:ok_or_error2(digraph(), - {'vertex', 'duplicate', digraph:vertex()} | - {'edge', ({bad_vertex, digraph:vertex()} | - {bad_edge, [digraph:vertex()]}), - digraph:vertex(), digraph:vertex()})). +-spec(all_module_attributes_with_app/1 :: + (atom()) -> [{atom(), atom(), [term()]}]). -spec(build_acyclic_graph/3 :: - (acyclic_graph_vertex_fun(), - acyclic_graph_edge_fun(), [{atom(), [term()]}]) + (graph_vertex_fun(), graph_edge_fun(), [{atom(), [term()]}]) -> rabbit_types:ok_or_error2(digraph(), {'vertex', 'duplicate', digraph:vertex()} | {'edge', ({bad_vertex, digraph:vertex()} | @@ -867,7 +856,7 @@ module_attributes(Module) -> V end. -all_app_module_attributes(Name) -> +all_module_attributes_with_app(Name) -> find_module_attributes( fun(App, Modules) -> [{App, Module} || Module <- Modules] @@ -900,31 +889,25 @@ find_module_attributes(Generator, Fold) -> {ok, Modules} <- [application:get_key(App, modules)]])), lists:foldl(Fold, [], Targets). -build_graph(VertexFun, EdgeFun, G) -> +build_acyclic_graph(VertexFun, EdgeFun, Graph) -> + G = digraph:new([acyclic]), try [case digraph:vertex(G, Vertex) of false -> digraph:add_vertex(G, Vertex, Label); _ -> ok = throw({graph_error, {vertex, duplicate, Vertex}}) - end || {Vertex, Label} <- VertexFun()], + end || {Module, Atts} <- Graph, + {Vertex, Label} <- VertexFun(Module, Atts)], [case digraph:add_edge(G, From, To) of {error, E} -> throw({graph_error, {edge, E, From, To}}); _ -> ok - end || {From, To} <- EdgeFun()], + end || {Module, Atts} <- Graph, + {From, To} <- EdgeFun(Module, Atts)], {ok, G} catch {graph_error, Reason} -> true = digraph:delete(G), {error, Reason} end. -build_acyclic_graph(VertexFun, EdgeFun, Graph) -> - build_graph(fun() -> [Vertex || {Module, Atts} <- Graph, - Vertex <- VertexFun(Module, Atts)] - end, - fun() -> [Edge || {Module, Atts} <- Graph, - Edge <- EdgeFun(Module, Atts)] - end, - digraph:new([acyclic])). - const_ok() -> ok. const(X) -> fun () -> X end. diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 81cebd99c8..6fe4c12788 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -38,8 +38,6 @@ %%---------------------------------------------------------------------------- -%% TODO: move all the {enable,disable}ment logic from plugins_main to here! - enable(Plugins) -> setup(), rabbit_boot:start(Plugins). diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index 47ece0395b..408fc4e10b 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -287,10 +287,6 @@ rpc_call(Node, Mod, Action, Args) -> case rpc:call(Node, Mod, Action, Args, ?RPC_TIMEOUT) of {badrpc, nodedown} -> io:format("Plugin configuration has changed.~n"); ok -> io:format("Plugin(s) ~pd.~n", [Action]); - %% QA question: if we get into a situation where the rpc call fails, - %% does it make sense to suggest a restart as we do here? The restart - %% would only succeed if the failure (here) was due to a bug in the - %% rabbit_plugins:enable/1 code afaict. Error -> io:format("Unable to ~p plugin(s). " "Please restart the broker " "to apply your changes.~nError: ~p~n", |
