Skip to content

Commit 0d692fa

Browse files
committed
Prefer node-local listeners helper in protocol-listener health check
This is a minor change that avoids a cluster-wide query for active listeners. The old code called `rabbit_networking:active_listeners/0` and then filtered the results by ones available on the local node. This caused an RPC and concatenation of all other cluster members' listeners and then in the next line filtered down to local nodes. Equivalently we can use `rabbit_networking:node_listeners(node())` which dumps a local ETS table. This is not a very impactful change but it's nice to keep the latency of the health-check handlers low and reduce some unnecessary cluster noise.
1 parent d27d5c4 commit 0d692fa

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

deps/rabbitmq_management/src/rabbit_mgmt_wm_health_check_protocol_listener.erl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ resource_exists(ReqData, Context) ->
3434

3535
to_json(ReqData, Context) ->
3636
Protocol = normalize_protocol(protocol(ReqData)),
37-
Listeners = rabbit_networking:active_listeners(),
38-
Local = [L || #listener{node = N} = L <- Listeners, N == node()],
39-
ProtoListeners = [L || #listener{protocol = P} = L <- Local, atom_to_list(P) == Protocol],
37+
Listeners = rabbit_networking:node_listeners(node()),
38+
ProtoListeners = [L || #listener{protocol = P} = L <- Listeners, atom_to_list(P) == Protocol],
4039
case ProtoListeners of
4140
[] ->
4241
Msg = <<"No active listener">>,
43-
failure(Msg, Protocol, [P || #listener{protocol = P} <- Local], ReqData, Context);
42+
failure(Msg, Protocol, [P || #listener{protocol = P} <- Listeners], ReqData, Context);
4443
_ ->
4544
Body = #{status => ok,
4645
protocol => list_to_binary(Protocol)},

0 commit comments

Comments
 (0)