refactor(emqx_mangement): update emqx_mangement for new listener,zone configs
This commit is contained in:
parent
4ea451e207
commit
7b63f7f18b
|
@ -37,6 +37,10 @@
|
|||
, has_enabled_listener_conf_by_type/1
|
||||
]).
|
||||
|
||||
-export([ listener_id/2
|
||||
, parse_listener_id/1
|
||||
]).
|
||||
|
||||
%% @doc List configured listeners.
|
||||
-spec(list() -> [{ListenerId :: atom(), ListenerConf :: map()}]).
|
||||
list() ->
|
||||
|
@ -264,7 +268,7 @@ format_addr({Addr, Port}) when is_tuple(Addr) ->
|
|||
listener_id(Type, ListenerName) ->
|
||||
list_to_atom(lists:append([atom_to_list(Type), ":", atom_to_list(ListenerName)])).
|
||||
|
||||
decode_listener_id(Id) ->
|
||||
parse_listener_id(Id) ->
|
||||
try
|
||||
[Zone, Listen] = string:split(atom_to_list(Id), ":", leading),
|
||||
{list_to_existing_atom(Zone), list_to_existing_atom(Listen)}
|
||||
|
@ -299,7 +303,7 @@ has_enabled_listener_conf_by_type(Type) ->
|
|||
end, do_list()).
|
||||
|
||||
apply_on_listener(ListenerId, Do) ->
|
||||
{Type, ListenerName} = decode_listener_id(ListenerId),
|
||||
{Type, ListenerName} = parse_listener_id(ListenerId),
|
||||
case emqx_config:find_listener_conf(Type, ListenerName, []) of
|
||||
{not_found, _, _} -> error({listener_config_not_found, Type, ListenerName});
|
||||
{ok, Conf} -> Do(Type, ListenerName, Conf)
|
||||
|
|
|
@ -277,15 +277,15 @@ format({error, Reason}) ->
|
|||
{error, Reason};
|
||||
|
||||
format({ID, Conf}) ->
|
||||
{Type, _Name} = emqx_listeners:parse_listener_id(ID),
|
||||
#{
|
||||
id => ID,
|
||||
node => maps:get(node, Conf),
|
||||
acceptors => maps:get(acceptors, Conf),
|
||||
max_conn => maps:get(max_connections, Conf),
|
||||
type => maps:get(type, Conf),
|
||||
type => Type,
|
||||
listen_on => list_to_binary(esockd:to_string(maps:get(bind, Conf))),
|
||||
running => trans_running(Conf),
|
||||
auth => maps:get(enable, maps:get(auth, Conf))
|
||||
running => trans_running(Conf)
|
||||
}.
|
||||
trans_running(Conf) ->
|
||||
case maps:get(running, Conf) of
|
||||
|
|
|
@ -117,8 +117,7 @@ comparison_listener(Local, Response) ->
|
|||
?assertEqual(maps:get(acceptors, Local), maps:get(<<"acceptors">>, Response)),
|
||||
?assertEqual(maps:get(max_conn, Local), maps:get(<<"max_conn">>, Response)),
|
||||
?assertEqual(maps:get(listen_on, Local), maps:get(<<"listen_on">>, Response)),
|
||||
?assertEqual(maps:get(running, Local), maps:get(<<"running">>, Response)),
|
||||
?assertEqual(maps:get(auth, Local), maps:get(<<"auth">>, Response)).
|
||||
?assertEqual(maps:get(running, Local), maps:get(<<"running">>, Response)).
|
||||
|
||||
|
||||
listener_stats(Listener, Stats) ->
|
||||
|
|
Loading…
Reference in New Issue