Skip to content

Commit

Permalink
Return Erlang node long name in metadata
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
acogoluegnes authored and michaelklishin committed Nov 17, 2020
1 parent f746ae7 commit d44888d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions deps/rabbitmq_stream/src/rabbit_stream.erl
Expand Up @@ -31,12 +31,21 @@ start(_Type, _Args) ->
host() ->
case application:get_env(rabbitmq_stream, advertised_host, undefined) of
undefined ->
{ok, Host} = inet:gethostname(),
list_to_binary(Host);
hostname_from_node();
Host ->
rabbit_data_coercion:to_binary(Host)
end.

hostname_from_node() ->
case re:split(rabbit_data_coercion:to_binary(node()),
"@",
[{return, binary}, {parts, 2}]) of
[_, Hostname] ->
Hostname;
[_] ->
rabbit_data_coercion:to_binary(inet:gethostname())
end.

port() ->
case application:get_env(rabbitmq_stream, advertised_port, undefined) of
undefined ->
Expand Down

0 comments on commit d44888d

Please sign in to comment.