Split out the params a bit, these should make it easier to edit...
This commit is contained in:
parent
9bf74e3868
commit
0a49fabded
|
|
@ -19,46 +19,54 @@
|
|||
|
||||
-include_lib("rabbit_common/include/rabbit.hrl").
|
||||
|
||||
-export([validate/2, notify/2]).
|
||||
-export([validate/3, notify/3]).
|
||||
-export([register/0]).
|
||||
|
||||
-rabbit_boot_step({?MODULE,
|
||||
[{description, "federation parameters"},
|
||||
{mfa, {rabbit_federation_parameters, register, []}},
|
||||
{mfa, {rabbit_registry, register,
|
||||
[runtime_parameter, <<"federation">>, ?MODULE]}},
|
||||
{requires, rabbit_registry},
|
||||
{enables, recovery}]}).
|
||||
|
||||
validate(upstream_sets, Term) ->
|
||||
io:format("Validate upstream_sets ~p~n", [Term]),
|
||||
register() ->
|
||||
[rabbit_registry:register(runtime_parameter, Name, ?MODULE) ||
|
||||
Name <- [<<"federation">>,
|
||||
<<"federation_connection">>,
|
||||
<<"federation_upstream_set">>]].
|
||||
|
||||
validate(federation_upstream_set, Key, Term) ->
|
||||
io:format("Validate upstream_set ~p ~p~n", [Key, Term]),
|
||||
ok;
|
||||
|
||||
validate(connections, Term) ->
|
||||
io:format("Validate connections ~p~n", [Term]),
|
||||
validate(federation_connection, Key, Term) ->
|
||||
io:format("Validate connections ~p ~p~n", [Key, Term]),
|
||||
ok;
|
||||
|
||||
validate(local_nodename, Term) ->
|
||||
validate(federation, <<"local_nodename">>, Term) ->
|
||||
io:format("Validate local_nodename ~p~n", [Term]),
|
||||
ok;
|
||||
|
||||
validate(local_username, Term) ->
|
||||
validate(federation, <<"local_username">>, Term) ->
|
||||
io:format("Validate local_username ~p~n", [Term]),
|
||||
ok;
|
||||
|
||||
validate(_Key, _Term) ->
|
||||
validate(_AppName, _Key, _Term) ->
|
||||
exit({error, key_not_recognised}).
|
||||
|
||||
notify(upstream_sets, Term) ->
|
||||
io:format("Notify upstream_sets ~p~n", [Term]),
|
||||
notify(federation_upstream_set, Key, Term) ->
|
||||
io:format("Notify upstream_sets ~p ~p~n", [Key, Term]),
|
||||
rabbit_federation_link_sup_sup:restart_everything();
|
||||
|
||||
notify(connections, Term) ->
|
||||
io:format("Notify connections ~p~n", [Term]),
|
||||
notify(federation_connection, Key, Term) ->
|
||||
io:format("Notify connections ~p ~p~n", [Key, Term]),
|
||||
rabbit_federation_link_sup_sup:restart_everything();
|
||||
|
||||
notify(local_nodename, Term) ->
|
||||
notify(federation, <<"local_nodename">>, Term) ->
|
||||
io:format("Notify local_nodename ~p~n", [Term]),
|
||||
rabbit_federation_link_sup_sup:restart_everything();
|
||||
|
||||
notify(local_username, Term) ->
|
||||
notify(federation, <<"local_username">>, Term) ->
|
||||
io:format("Notify local_username ~p~n", [Term]),
|
||||
rabbit_federation_link_sup_sup:restart_everything().
|
||||
|
|
|
|||
|
|
@ -58,9 +58,7 @@ print(Fmt, Args) -> iolist_to_binary(io_lib:format(Fmt, Args)).
|
|||
|
||||
from_set(SetName, #resource{name = DefaultXNameBin,
|
||||
virtual_host = DefaultVHost}) ->
|
||||
Sets = rabbit_runtime_parameters:value(
|
||||
federation, upstream_sets, [{"upstreams", []}]),
|
||||
case pget(SetName, Sets) of
|
||||
case rabbit_runtime_parameters:value(federation_upstream_set, SetName) of
|
||||
undefined -> {error, set_not_found};
|
||||
Set -> Results = [from_props(P, DefaultXNameBin, DefaultVHost) ||
|
||||
P <- Set],
|
||||
|
|
@ -71,11 +69,11 @@ from_set(SetName, #resource{name = DefaultXNameBin,
|
|||
end.
|
||||
|
||||
from_props(Upst, DefaultXNameBin, DefaultVHost) ->
|
||||
Connections = rabbit_runtime_parameters:value(federation, connections, []),
|
||||
case bget(connection, Upst) of
|
||||
undefined -> {error, no_connection_name};
|
||||
ConnName -> case pget(ConnName, Connections) of
|
||||
undefined -> {error, {no_connection, ConnName}};
|
||||
ConnName -> case rabbit_runtime_parameters:value(
|
||||
federation_connection, ConnName) of
|
||||
not_found -> {error, {no_connection, ConnName}};
|
||||
Conn -> from_props_connection(
|
||||
Upst, ConnName, Conn, DefaultXNameBin,
|
||||
DefaultVHost)
|
||||
|
|
|
|||
Loading…
Reference in New Issue