Skip to content

Commit b2acccf

Browse files
Merge pull request #10256 from ariel-anieli/issue-2640-client--properties-also-maps
[2640] client_properties accepted as either a proplists, or a map
2 parents d258626 + 12648bd commit b2acccf

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

deps/amqp_client/src/amqp_connection.erl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@
8888
%% <li>node :: atom() - The node the broker runs on (direct only)</li>
8989
%% <li>adapter_info :: amqp_adapter_info() - Extra management information for if
9090
%% this connection represents a non-AMQP network connection.</li>
91-
%% <li>client_properties :: [{binary(), atom(), binary()}] - A list of extra
92-
%% client properties to be sent to the server, defaults to []</li>
91+
%% <li>client_properties :: [{binary(), atom(), binary()}]
92+
%% | #{binary() => binary()}
93+
%% - A list (or a map) of extra client properties to be sent to the server,
94+
%% defaults to []</li>
9395
%% </ul>
9496
%%
9597
%% @type amqp_params_network() = #amqp_params_network{}.
@@ -116,8 +118,10 @@
116118
%% defaults to 30000 (network only)</li>
117119
%% <li>ssl_options :: term() - The second parameter to be used with the
118120
%% ssl:connect/2 function, defaults to 'none' (network only)</li>
119-
%% <li>client_properties :: [{binary(), atom(), binary()}] - A list of extra
120-
%% client properties to be sent to the server, defaults to []</li>
121+
%% <li>client_properties :: [{binary(), atom(), binary()}]
122+
%% | #{binary() => binary()}
123+
%% - A list (or a map) of extra client properties to be sent to the server,
124+
%% defaults to []</li>
121125
%% <li>socket_options :: [any()] - Extra socket options. These are
122126
%% appended to the default options. See
123127
%% <a href="https://www.erlang.org/doc/man/inet.html#setopts-2">inet:setopts/2</a>
@@ -155,10 +159,12 @@ start(AmqpParams, ConnName) when ConnName == undefined; is_binary(ConnName) ->
155159
ensure_started(),
156160
AmqpParams0 =
157161
case AmqpParams of
158-
#amqp_params_direct{password = Password} ->
159-
AmqpParams#amqp_params_direct{password = credentials_obfuscation:encrypt(Password)};
160-
#amqp_params_network{password = Password} ->
161-
AmqpParams#amqp_params_network{password = credentials_obfuscation:encrypt(Password)}
162+
#amqp_params_direct{password = Password, client_properties = Props} ->
163+
AmqpParams#amqp_params_direct{password = credentials_obfuscation:encrypt(Password),
164+
client_properties = rabbit_data_coercion:to_proplist(Props)};
165+
#amqp_params_network{password = Password, client_properties = Props} ->
166+
AmqpParams#amqp_params_network{password = credentials_obfuscation:encrypt(Password),
167+
client_properties = rabbit_data_coercion:to_proplist(Props)}
162168
end,
163169
AmqpParams1 =
164170
case AmqpParams0 of

0 commit comments

Comments
 (0)