66% %
77-module (rabbit_amqp1_0 ).
88
9- -export ([connection_info_local /1 ,
10- emit_connection_info_local /3 ,
9+ -export ([emit_connection_info_local /3 ,
1110 emit_connection_info_all /4 ,
12- list /0 ]).
11+ list /0 ,
12+ register_connection /1 ,
13+ unregister_connection /1 ]).
1314
1415emit_connection_info_all (Nodes , Items , Ref , AggregatorPid ) ->
1516 Pids = [spawn_link (Node , rabbit_amqp1_0 , emit_connection_info_local ,
@@ -26,17 +27,14 @@ emit_connection_info_local(Items, Ref, AggregatorPid) ->
2627 end ,
2728 list ()).
2829
29- connection_info_local (Items ) ->
30- Connections = list (),
31- [rabbit_amqp1_0_reader :info (Pid , Items ) || Pid <- Connections ].
32-
30+ -spec list () -> [pid ()].
3331list () ->
34- [ ReaderPid
35- || { _ , TcpPid , _ , [ tcp_listener_sup ]} <- supervisor : which_children ( rabbit_sup ),
36- { _ , RanchEPid , _ , [ ranch_embedded_sup ]} <- supervisor : which_children ( TcpPid ),
37- { _ , RanchLPid , _ , [ ranch_listener_sup ]} <- supervisor : which_children ( RanchEPid ),
38- { _ , RanchCSPid , _ , [ ranch_conns_sup_sup ]} <- supervisor : which_children ( RanchLPid ),
39- { _ , RanchCPid , _ , [ ranch_conns_sup ]} <- supervisor : which_children ( RanchCSPid ),
40- { rabbit_connection_sup , ConnPid , _ , _ } <- supervisor : which_children ( RanchCPid ),
41- { reader , ReaderPid , _ , _ } <- supervisor : which_children ( ConnPid )
42- ] .
32+ pg_local : get_members ( rabbit_amqp10_connections ).
33+
34+ - spec register_connection ( pid ()) -> ok .
35+ register_connection ( Pid ) ->
36+ pg_local : join ( rabbit_amqp10_connections , Pid ).
37+
38+ - spec unregister_connection ( pid ()) -> ok .
39+ unregister_connection ( Pid ) ->
40+ pg_local : leave ( rabbit_amqp10_connections , Pid ) .
0 commit comments