Skip to content

Commit

Permalink
Reuse list_local_connection_of_protocol for stomp
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisSotoLopez committed Mar 14, 2024
1 parent 5381c66 commit 5e15082
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions deps/rabbitmq_stomp/include/rabbit_stomp.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
ssl_cert_login}).

-define(SUPPORTED_VERSIONS, ["1.0", "1.1", "1.2"]).
-define(STOMP_TCP_PROTOCOL, 'stomp').
-define(STOMP_TLS_PROTOCOL, 'stomp/ssl').

-define(INFO_ITEMS,
[conn_name,
Expand Down
24 changes: 12 additions & 12 deletions deps/rabbitmq_stomp/src/rabbit_stomp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-export([connection_info_local/1,
emit_connection_info_local/3,
emit_connection_info_all/4,
list/0,
list_local_stomp_connections/0,
close_all_client_connections/1]).

-define(DEFAULT_CONFIGURATION,
Expand All @@ -41,7 +41,7 @@ stop(_) ->

-spec close_all_client_connections(string() | binary()) -> {'ok', non_neg_integer()}.
close_all_client_connections(Reason) ->
Connections = list(),
Connections = list_local_stomp_connections(),
[rabbit_stomp_reader:close_connection(Pid, Reason) || Pid <- Connections],
{ok, length(Connections)}.

Expand All @@ -57,10 +57,10 @@ emit_connection_info_local(Items, Ref, AggregatorPid) ->
AggregatorPid, Ref, fun(Pid) ->
rabbit_stomp_reader:info(Pid, Items)
end,
list()).
list_local_stomp_connections()).

connection_info_local(Items) ->
Connections = list(),
Connections = list_local_stomp_connections(),
[rabbit_stomp_reader:info(Pid, Items) || Pid <- Connections].

parse_listener_configuration() ->
Expand Down Expand Up @@ -113,12 +113,12 @@ report_configuration(#stomp_configuration{

ok.

list() ->
list_local_stomp_connections() ->
PlainPids = rabbit_networking:list_local_connections_of_protocol(?STOMP_TCP_PROTOCOL),
TLSPids = rabbit_networking:list_local_connections_of_protocol(?STOMP_TLS_PROTOCOL),
AllPids = PlainPids ++ TLSPids,
[Client ||
{_, ListSup, _, _} <- supervisor:which_children(rabbit_stomp_sup),
{_, RanchEmbeddedSup, supervisor, _} <- supervisor:which_children(ListSup),
{{ranch_listener_sup, _}, RanchListSup, _, _} <- supervisor:which_children(RanchEmbeddedSup),
{ranch_conns_sup_sup, RanchConnsSup, supervisor, _} <- supervisor:which_children(RanchListSup),
{_, RanchConnSup, supervisor, _} <- supervisor:which_children(RanchConnsSup),
{_, StompClientSup, supervisor, _} <- supervisor:which_children(RanchConnSup),
{rabbit_stomp_reader, Client, _, _} <- supervisor:which_children(StompClientSup)].
StompSupervisor <- AllPids,
{rabbit_stomp_reader, Client, _, _} <-
supervisor:which_children(StompSupervisor)
].

0 comments on commit 5e15082

Please sign in to comment.