Use rabbit_data_coercion functions here

This commit is contained in:
Michael Klishin 2021-09-21 20:01:19 +03:00
parent 7aedc45d1f
commit 1c09040533
No known key found for this signature in database
GPG Key ID: E80EDCFA0CDB21EE
1 changed files with 6 additions and 7 deletions

View File

@ -11,7 +11,7 @@
-export([start_link/0, init/1, adjust/2, stop_child/1, cleanup_specs/0]).
-import(rabbit_misc, [pget/2]).
-import(proplists, [to_map/1, from_map/1]).
-import(rabbit_data_coercion, [to_map/1, to_list/1]).
-include("rabbit_shovel.hrl").
-include_lib("rabbit_common/include/rabbit.hrl").
@ -43,7 +43,7 @@ start_child({VHost, ShovelName} = Name, Def) ->
rabbit_log_shovel:debug("Starting a mirrored supervisor named '~s' in virtual host '~s'", [ShovelName, VHost]),
Result = case mirrored_supervisor:start_child(
?SUPERVISOR,
{Name, {rabbit_shovel_dyn_worker_sup, start_link, [Name, get_obfuscate_uris_parameters(Def)]},
{Name, {rabbit_shovel_dyn_worker_sup, start_link, [Name, obfuscated_uris_parameters(Def)]},
transient, ?WORKER_WAIT, worker, [rabbit_shovel_dyn_worker_sup]}) of
{ok, _Pid} -> ok;
{error, {already_started, _Pid}} -> ok
@ -52,11 +52,10 @@ start_child({VHost, ShovelName} = Name, Def) ->
rabbit_shovel_locks:unlock(LockId),
Result.
get_obfuscate_uris_parameters(Def) ->
case Def of
M when is_map(M) -> to_map(rabbit_shovel_parameters:obfuscate_uris_parameters(from_map(Def)));
_ -> rabbit_shovel_parameters:obfuscate_uris_parameters(Def)
end.
obfuscated_uris_parameters(Def) when is_map(Def) ->
to_map(rabbit_shovel_parameters:obfuscate_uris_parameters(to_list(Def)));
obfuscated_uris_parameters(Def) when is_list(Def) ->
rabbit_shovel_parameters:obfuscate_uris_parameters(Def).
child_exists(Name) ->
lists:any(fun ({N, _, _, _}) -> N =:= Name end,