diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2018-11-30 11:30:36 +0100 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2019-02-01 11:23:16 +0100 |
| commit | 5bbde6d0a3eb1790d4965d76c8699d0187b74183 (patch) | |
| tree | df1cd4f48442a8e79d45e35c255cd28851dee63d /src/rabbit.erl | |
| parent | d142bbc45a4d0f8482b6a98d1f16a725cdf8d8a8 (diff) | |
| download | rabbitmq-server-git-5bbde6d0a3eb1790d4965d76c8699d0187b74183.tar.gz | |
Move `-spec()` near their function
Diffstat (limited to 'src/rabbit.erl')
| -rw-r--r-- | src/rabbit.erl | 93 |
1 files changed, 57 insertions, 36 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index e06e50561d..2d16661768 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -33,6 +33,8 @@ -export([log_locations/0, config_files/0, decrypt_config/2]). %% for testing and mgmt-agent -export([is_booted/1, is_booted/0, is_booting/1, is_booting/0]). +-deprecated([{force_event_refresh, 1, eventually}]). + -ifdef(TEST). -export([start_logger/0]). @@ -257,42 +259,6 @@ -type param() :: atom(). -type app_name() :: atom(). --spec start() -> 'ok'. --spec boot() -> 'ok'. --spec stop() -> 'ok'. --spec stop_and_halt() -> no_return(). - --spec status - () -> [{pid, integer()} | - {running_applications, [{atom(), string(), string()}]} | - {os, {atom(), atom()}} | - {erlang_version, string()} | - {memory, any()}]. --spec is_running() -> boolean(). --spec is_running(node()) -> boolean(). --spec environment() -> [{param(), term()}]. --spec rotate_logs() -> rabbit_types:ok_or_error(any()). --deprecated([{force_event_refresh, 1, eventually}]). --spec force_event_refresh(reference()) -> 'ok'. - --spec log_locations() -> [log_location()]. - --spec start('normal',[]) -> - {'error', - {'erlang_version_too_old', - {'found',string(),string()}, - {'required',string(),string()}}} | - {'ok',pid()}. --spec stop(_) -> 'ok'. - --spec maybe_insert_default_data() -> 'ok'. --spec boot_delegate() -> 'ok'. --spec recover() -> 'ok'. --spec start_apps([app_name()]) -> 'ok'. --spec start_apps([app_name()], - #{app_name() => restart_type()}) -> 'ok'. --spec stop_apps([app_name()]) -> 'ok'. - %%---------------------------------------------------------------------------- ensure_application_loaded() -> @@ -304,6 +270,8 @@ ensure_application_loaded() -> {error, {already_loaded, rabbit}} -> ok end. +-spec start() -> 'ok'. + start() -> start_it(fun() -> %% We do not want to upgrade mnesia after just @@ -317,6 +285,8 @@ start() -> broker_start() end). +-spec boot() -> 'ok'. + boot() -> start_it(fun() -> ensure_config(), @@ -494,6 +464,8 @@ start_it(StartFun) -> Marker ! stop end. +-spec stop() -> 'ok'. + stop() -> case whereis(rabbit_boot) of undefined -> ok; @@ -508,6 +480,8 @@ stop() -> stop_apps(app_utils:app_dependency_order(Apps, true)), rabbit_log:info("Successfully stopped RabbitMQ and its dependencies~n", []). +-spec stop_and_halt() -> no_return(). + stop_and_halt() -> try stop() @@ -533,9 +507,14 @@ stop_and_halt() -> end, ok. +-spec start_apps([app_name()]) -> 'ok'. + start_apps(Apps) -> start_apps(Apps, #{}). +-spec start_apps([app_name()], + #{app_name() => restart_type()}) -> 'ok'. + start_apps(Apps, RestartTypes) -> app_utils:load_applications(Apps), rabbit_feature_flags:initialize_registry(), @@ -678,6 +657,8 @@ decrypt_list([{Key, Value}|Tail], Algo, Acc) when Key =/= encrypted -> decrypt_list([Value|Tail], Algo, Acc) -> decrypt_list(Tail, Algo, [decrypt(Value, Algo)|Acc]). +-spec stop_apps([app_name()]) -> 'ok'. + stop_apps([]) -> ok; stop_apps(Apps) -> @@ -712,16 +693,19 @@ is_booting(Node) -> -spec await_startup() -> 'ok' | {'error', 'timeout'}. + await_startup() -> await_startup(node(), false). -spec await_startup(node() | non_neg_integer()) -> 'ok' | {'error', 'timeout'}. + await_startup(Node) when is_atom(Node) -> await_startup(Node, false); await_startup(Timeout) when is_integer(Timeout) -> await_startup(node(), false, Timeout). -spec await_startup(node(), boolean()) -> 'ok' | {'error', 'timeout'}. + await_startup(Node, PrintProgressReports) -> case is_booting(Node) of true -> wait_for_boot_to_finish(Node, PrintProgressReports); @@ -734,6 +718,7 @@ await_startup(Node, PrintProgressReports) -> end. -spec await_startup(node(), boolean(), non_neg_integer()) -> 'ok' | {'error', 'timeout'}. + await_startup(Node, PrintProgressReports, Timeout) -> case is_booting(Node) of true -> wait_for_boot_to_finish(Node, PrintProgressReports, Timeout); @@ -805,6 +790,13 @@ maybe_print_boot_progress(true, IterationsLeft) -> _ -> ok end. +-spec status + () -> [{pid, integer()} | + {running_applications, [{atom(), string(), string()}]} | + {os, {atom(), atom()}} | + {erlang_version, string()} | + {memory, any()}]. + status() -> S1 = [{pid, list_to_integer(os:getpid())}, %% The timeout value used is twice that of gen_server:call/2. @@ -860,8 +852,13 @@ listeners() -> %% TODO this only determines if the rabbit application has started, %% not if it is running, never mind plugins. It would be nice to have %% more nuance here. + +-spec is_running() -> boolean(). + is_running() -> is_running(node()). +-spec is_running(node()) -> boolean(). + is_running(Node) -> rabbit_nodes:is_process_running(Node, rabbit). is_booted() -> is_booted(node()). @@ -873,6 +870,8 @@ is_booted(Node) -> _ -> false end. +-spec environment() -> [{param(), term()}]. + environment() -> %% The timeout value is twice that of gen_server:call/2. [{A, environment(A)} || @@ -883,6 +882,8 @@ environment(App) -> lists:keysort(1, [P || P = {K, _} <- application:get_all_env(App), not lists:member(K, Ignore)]). +-spec rotate_logs() -> rabbit_types:ok_or_error(any()). + rotate_logs() -> rabbit_lager:fold_sinks( fun @@ -906,6 +907,13 @@ rotate_logs() -> %%-------------------------------------------------------------------- +-spec start('normal',[]) -> + {'error', + {'erlang_version_too_old', + {'found',string(),string()}, + {'required',string(),string()}}} | + {'ok',pid()}. + start(normal, []) -> case erts_version_check() of ok -> @@ -938,6 +946,8 @@ prep_stop(State) -> rabbit_peer_discovery:maybe_unregister(), State. +-spec stop(_) -> 'ok'. + stop(_State) -> ok = rabbit_alarm:stop(), ok = case rabbit_mnesia:is_clustered() of @@ -992,14 +1002,20 @@ log_boot_error_and_exit(Reason, Format, Args) -> %%--------------------------------------------------------------------------- %% boot step functions +-spec boot_delegate() -> 'ok'. + boot_delegate() -> {ok, Count} = application:get_env(rabbit, delegate_count), rabbit_sup:start_supervisor_child(delegate_sup, [Count]). +-spec recover() -> 'ok'. + recover() -> rabbit_policy:recover(), rabbit_vhost:recover(). +-spec maybe_insert_default_data() -> 'ok'. + maybe_insert_default_data() -> case rabbit_table:needs_default_data() of true -> insert_default_data(); @@ -1044,12 +1060,17 @@ start_logger() -> rabbit_lager:start_logger(), ok. +-spec log_locations() -> [log_location()]. + log_locations() -> rabbit_lager:log_locations(). %% This feature was used by the management API up-to and including %% RabbitMQ 3.7.x. It is unused in 3.8.x and thus deprecated. We keep it %% to support in-place upgrades to 3.8.x (i.e. mixed-version clusters). + +-spec force_event_refresh(reference()) -> 'ok'. + force_event_refresh(Ref) -> rabbit_direct:force_event_refresh(Ref), rabbit_networking:force_connection_event_refresh(Ref), |
