Skip to content

Commit ea91e93

Browse files
committed
Return Erlang node long name in metadata
Fixes #2
1 parent 1ee6da9 commit ea91e93

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/rabbit_stream.erl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ start(_Type, _Args) ->
3131
host() ->
3232
case application:get_env(rabbitmq_stream, advertised_host, undefined) of
3333
undefined ->
34-
{ok, Host} = inet:gethostname(),
35-
list_to_binary(Host);
34+
hostname_from_node();
3635
Host ->
3736
rabbit_data_coercion:to_binary(Host)
3837
end.
3938

39+
hostname_from_node() ->
40+
case re:split(rabbit_data_coercion:to_binary(node()),
41+
"@",
42+
[{return, binary}, {parts, 2}]) of
43+
[_, Hostname] ->
44+
Hostname;
45+
[_] ->
46+
rabbit_data_coercion:to_binary(inet:gethostname())
47+
end.
48+
4049
port() ->
4150
case application:get_env(rabbitmq_stream, advertised_port, undefined) of
4251
undefined ->

0 commit comments

Comments
 (0)