aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjuhlig <[email protected]>2019-07-17 16:02:47 +0200
committerLoïc Hoguin <[email protected]>2019-07-18 09:35:56 +0200
commitaf739162fd43d46f2562af96c56147054457518e (patch)
tree51d5c937c3ee0af17c8cbe75d0f7bcd70aacfa91 /src
parentd017c0f5860bc1a5c775c9a61db407e29c575f80 (diff)
downloadranch-af739162fd43d46f2562af96c56147054457518e.tar.gz
ranch-af739162fd43d46f2562af96c56147054457518e.tar.bz2
ranch-af739162fd43d46f2562af96c56147054457518e.zip
Return listener info as a map2.0.0-rc.1
Diffstat (limited to 'src')
-rw-r--r--src/ranch.erl39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index 94727ea..08eebfc 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -315,12 +315,17 @@ get_protocol_options(Ref) ->
set_protocol_options(Ref, Opts) ->
ranch_server:set_protocol_options(Ref, Opts).
--spec info() -> [{any(), [{atom(), any()}]}].
+-spec info() -> #{ref() := #{atom() := term()}}.
info() ->
- [{Ref, listener_info(Ref, Pid)}
- || {Ref, Pid} <- ranch_server:get_listener_sups()].
+ lists:foldl(
+ fun ({Ref, Pid}, Acc) ->
+ Acc#{Ref => listener_info(Ref, Pid)}
+ end,
+ #{},
+ ranch_server:get_listener_sups()
+ ).
--spec info(ref()) -> [{atom(), any()}].
+-spec info(ref()) -> #{atom() := term()}.
info(Ref) ->
Pid = ranch_server:get_listener_sup(Ref),
listener_info(Ref, Pid).
@@ -337,19 +342,19 @@ listener_info(Ref, Pid) ->
MaxConns = get_max_connections(Ref),
TransOpts = ranch_server:get_transport_options(Ref),
ProtoOpts = get_protocol_options(Ref),
- [
- {pid, Pid},
- {status, Status},
- {ip, IP},
- {port, Port},
- {max_connections, MaxConns},
- {active_connections, get_connections(Ref, active)},
- {all_connections, get_connections(Ref, all)},
- {transport, Transport},
- {transport_options, TransOpts},
- {protocol, Protocol},
- {protocol_options, ProtoOpts}
- ].
+ #{
+ pid => Pid,
+ status => Status,
+ ip => IP,
+ port => Port,
+ max_connections => MaxConns,
+ active_connections => get_connections(Ref, active),
+ all_connections => get_connections(Ref, all),
+ transport => Transport,
+ transport_options => TransOpts,
+ protocol => Protocol,
+ protocol_options => ProtoOpts
+ }.
-spec procs(ref(), acceptors | connections) -> [pid()].
procs(Ref, Type) ->