Skip to content

Commit

Permalink
Merge pull request #10256 from ariel-anieli/issue-2640-client--proper…
Browse files Browse the repository at this point in the history
…ties-also-maps

[2640] client_properties accepted as either a proplists, or a map
  • Loading branch information
michaelklishin authored Jan 4, 2024
2 parents d258626 + 12648bd commit b2acccf
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions deps/amqp_client/src/amqp_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@
%% <li>node :: atom() - The node the broker runs on (direct only)</li>
%% <li>adapter_info :: amqp_adapter_info() - Extra management information for if
%% this connection represents a non-AMQP network connection.</li>
%% <li>client_properties :: [{binary(), atom(), binary()}] - A list of extra
%% client properties to be sent to the server, defaults to []</li>
%% <li>client_properties :: [{binary(), atom(), binary()}]
%% | #{binary() => binary()}
%% - A list (or a map) of extra client properties to be sent to the server,
%% defaults to []</li>
%% </ul>
%%
%% @type amqp_params_network() = #amqp_params_network{}.
Expand All @@ -116,8 +118,10 @@
%% defaults to 30000 (network only)</li>
%% <li>ssl_options :: term() - The second parameter to be used with the
%% ssl:connect/2 function, defaults to 'none' (network only)</li>
%% <li>client_properties :: [{binary(), atom(), binary()}] - A list of extra
%% client properties to be sent to the server, defaults to []</li>
%% <li>client_properties :: [{binary(), atom(), binary()}]
%% | #{binary() => binary()}
%% - A list (or a map) of extra client properties to be sent to the server,
%% defaults to []</li>
%% <li>socket_options :: [any()] - Extra socket options. These are
%% appended to the default options. See
%% <a href="https://www.erlang.org/doc/man/inet.html#setopts-2">inet:setopts/2</a>
Expand Down Expand Up @@ -155,10 +159,12 @@ start(AmqpParams, ConnName) when ConnName == undefined; is_binary(ConnName) ->
ensure_started(),
AmqpParams0 =
case AmqpParams of
#amqp_params_direct{password = Password} ->
AmqpParams#amqp_params_direct{password = credentials_obfuscation:encrypt(Password)};
#amqp_params_network{password = Password} ->
AmqpParams#amqp_params_network{password = credentials_obfuscation:encrypt(Password)}
#amqp_params_direct{password = Password, client_properties = Props} ->
AmqpParams#amqp_params_direct{password = credentials_obfuscation:encrypt(Password),
client_properties = rabbit_data_coercion:to_proplist(Props)};
#amqp_params_network{password = Password, client_properties = Props} ->
AmqpParams#amqp_params_network{password = credentials_obfuscation:encrypt(Password),
client_properties = rabbit_data_coercion:to_proplist(Props)}
end,
AmqpParams1 =
case AmqpParams0 of
Expand Down

0 comments on commit b2acccf

Please sign in to comment.