fix: alias listeners.Type.Name.enabled as listeners.Type.Name.enable
This commit is contained in:
parent
82672ff095
commit
d781346efc
|
@ -368,7 +368,7 @@ console_print(_Fmt, _Args) -> ok.
|
||||||
%% Start MQTT/TCP listener
|
%% Start MQTT/TCP listener
|
||||||
-spec do_start_listener(atom(), atom(), map()) ->
|
-spec do_start_listener(atom(), atom(), map()) ->
|
||||||
{ok, pid() | {skipped, atom()}} | {error, term()}.
|
{ok, pid() | {skipped, atom()}} | {error, term()}.
|
||||||
do_start_listener(_Type, _ListenerName, #{enabled := false}) ->
|
do_start_listener(_Type, _ListenerName, #{enable := false}) ->
|
||||||
{ok, {skipped, listener_disabled}};
|
{ok, {skipped, listener_disabled}};
|
||||||
do_start_listener(Type, ListenerName, #{bind := ListenOn} = Opts) when
|
do_start_listener(Type, ListenerName, #{bind := ListenOn} = Opts) when
|
||||||
Type == tcp; Type == ssl
|
Type == tcp; Type == ssl
|
||||||
|
@ -499,8 +499,8 @@ post_config_update([?ROOT_KEY, Type, Name], {update, _Request}, NewConf, OldConf
|
||||||
post_config_update([?ROOT_KEY, Type, Name], ?MARK_DEL, _, OldConf = #{}, _AppEnvs) ->
|
post_config_update([?ROOT_KEY, Type, Name], ?MARK_DEL, _, OldConf = #{}, _AppEnvs) ->
|
||||||
remove_listener(Type, Name, OldConf);
|
remove_listener(Type, Name, OldConf);
|
||||||
post_config_update([?ROOT_KEY, Type, Name], {action, _Action, _}, NewConf, OldConf, _AppEnvs) ->
|
post_config_update([?ROOT_KEY, Type, Name], {action, _Action, _}, NewConf, OldConf, _AppEnvs) ->
|
||||||
#{enabled := NewEnabled} = NewConf,
|
#{enable := NewEnabled} = NewConf,
|
||||||
#{enabled := OldEnabled} = OldConf,
|
#{enable := OldEnabled} = OldConf,
|
||||||
case {NewEnabled, OldEnabled} of
|
case {NewEnabled, OldEnabled} of
|
||||||
{true, true} ->
|
{true, true} ->
|
||||||
ok = maybe_unregister_ocsp_stapling_refresh(Type, Name, NewConf),
|
ok = maybe_unregister_ocsp_stapling_refresh(Type, Name, NewConf),
|
||||||
|
@ -810,7 +810,7 @@ has_enabled_listener_conf_by_type(Type) ->
|
||||||
lists:any(
|
lists:any(
|
||||||
fun({Id, LConf}) when is_map(LConf) ->
|
fun({Id, LConf}) when is_map(LConf) ->
|
||||||
{ok, #{type := Type0}} = parse_listener_id(Id),
|
{ok, #{type := Type0}} = parse_listener_id(Id),
|
||||||
Type =:= Type0 andalso maps:get(enabled, LConf, true)
|
Type =:= Type0 andalso maps:get(enable, LConf, true)
|
||||||
end,
|
end,
|
||||||
list()
|
list()
|
||||||
).
|
).
|
||||||
|
|
|
@ -1750,13 +1750,12 @@ mqtt_listener(Bind) ->
|
||||||
|
|
||||||
base_listener(Bind) ->
|
base_listener(Bind) ->
|
||||||
[
|
[
|
||||||
{"enabled",
|
{"enable",
|
||||||
sc(
|
sc(
|
||||||
boolean(),
|
boolean(),
|
||||||
#{
|
#{
|
||||||
default => true,
|
default => true,
|
||||||
%% TODO(5.2): change field name to 'enable' and keep 'enabled' as an alias
|
aliases => [enabled],
|
||||||
aliases => [enable],
|
|
||||||
desc => ?DESC(fields_listener_enabled)
|
desc => ?DESC(fields_listener_enabled)
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
|
|
|
@ -510,9 +510,9 @@ action_listeners_by_id(post, #{bindings := #{id := Id, action := Action}}) ->
|
||||||
|
|
||||||
%%%==============================================================================================
|
%%%==============================================================================================
|
||||||
|
|
||||||
enabled(start) -> #{<<"enabled">> => true};
|
enabled(start) -> #{<<"enable">> => true};
|
||||||
enabled(stop) -> #{<<"enabled">> => false};
|
enabled(stop) -> #{<<"enable">> => false};
|
||||||
enabled(restart) -> #{<<"enabled">> => true}.
|
enabled(restart) -> #{<<"enable">> => true}.
|
||||||
|
|
||||||
err_msg(Atom) when is_atom(Atom) -> atom_to_binary(Atom);
|
err_msg(Atom) when is_atom(Atom) -> atom_to_binary(Atom);
|
||||||
err_msg(Reason) -> list_to_binary(err_msg_str(Reason)).
|
err_msg(Reason) -> list_to_binary(err_msg_str(Reason)).
|
||||||
|
@ -594,7 +594,7 @@ format_status(Key, Node, Listener, Acc) ->
|
||||||
#{
|
#{
|
||||||
<<"id">> := Id,
|
<<"id">> := Id,
|
||||||
<<"type">> := Type,
|
<<"type">> := Type,
|
||||||
<<"enabled">> := Enabled,
|
<<"enable">> := Enable,
|
||||||
<<"running">> := Running,
|
<<"running">> := Running,
|
||||||
<<"max_connections">> := MaxConnections,
|
<<"max_connections">> := MaxConnections,
|
||||||
<<"current_connections">> := CurrentConnections,
|
<<"current_connections">> := CurrentConnections,
|
||||||
|
@ -609,7 +609,7 @@ format_status(Key, Node, Listener, Acc) ->
|
||||||
GroupKey => #{
|
GroupKey => #{
|
||||||
name => Name,
|
name => Name,
|
||||||
type => Type,
|
type => Type,
|
||||||
enable => Enabled,
|
enable => Enable,
|
||||||
ids => [Id],
|
ids => [Id],
|
||||||
acceptors => Acceptors,
|
acceptors => Acceptors,
|
||||||
bind => iolist_to_binary(emqx_listeners:format_bind(Bind)),
|
bind => iolist_to_binary(emqx_listeners:format_bind(Bind)),
|
||||||
|
|
Loading…
Reference in New Issue