Merge pull request #11226 from zhongwencool/listener-conf-enabled-to-enable
fix: alias listeners.Type.Name.enabled as listeners.Type.Name.enable
This commit is contained in:
commit
f144bb0571
|
@ -370,7 +370,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
|
||||||
|
@ -501,8 +501,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),
|
||||||
|
@ -812,7 +812,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)
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
|
|
|
@ -618,7 +618,7 @@ ensure_quic_listener(Name, UdpPort, ExtraSettings) ->
|
||||||
"TLS_AES_128_GCM_SHA256",
|
"TLS_AES_128_GCM_SHA256",
|
||||||
"TLS_CHACHA20_POLY1305_SHA256"
|
"TLS_CHACHA20_POLY1305_SHA256"
|
||||||
],
|
],
|
||||||
enabled => true,
|
enable => true,
|
||||||
idle_timeout => 15000,
|
idle_timeout => 15000,
|
||||||
ssl_options => #{
|
ssl_options => #{
|
||||||
certfile => filename:join(code:lib_dir(emqx), "etc/certs/cert.pem"),
|
certfile => filename:join(code:lib_dir(emqx), "etc/certs/cert.pem"),
|
||||||
|
|
|
@ -229,7 +229,7 @@ t_ssl_password_cert(Config) ->
|
||||||
keyfile => filename:join(DataDir, "server-password.key")
|
keyfile => filename:join(DataDir, "server-password.key")
|
||||||
},
|
},
|
||||||
LConf = #{
|
LConf = #{
|
||||||
enabled => true,
|
enable => true,
|
||||||
bind => {{127, 0, 0, 1}, Port},
|
bind => {{127, 0, 0, 1}, Port},
|
||||||
mountpoint => <<>>,
|
mountpoint => <<>>,
|
||||||
zone => default,
|
zone => default,
|
||||||
|
|
|
@ -363,14 +363,14 @@ listeners_test() ->
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
#{
|
#{
|
||||||
<<"bind">> := {{0, 0, 0, 0}, 1883},
|
<<"bind">> := {{0, 0, 0, 0}, 1883},
|
||||||
<<"enabled">> := true
|
<<"enable">> := true
|
||||||
},
|
},
|
||||||
Tcp
|
Tcp
|
||||||
),
|
),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
#{
|
#{
|
||||||
<<"bind">> := {{0, 0, 0, 0}, 8083},
|
<<"bind">> := {{0, 0, 0, 0}, 8083},
|
||||||
<<"enabled">> := true,
|
<<"enable">> := true,
|
||||||
<<"websocket">> := #{<<"mqtt_path">> := "/mqtt"}
|
<<"websocket">> := #{<<"mqtt_path">> := "/mqtt"}
|
||||||
},
|
},
|
||||||
Ws
|
Ws
|
||||||
|
|
|
@ -84,7 +84,7 @@ start_cluster(NamesWithPorts, Apps, Env) ->
|
||||||
{env, [{emqx, boot_modules, [broker, listeners]}] ++ Env},
|
{env, [{emqx, boot_modules, [broker, listeners]}] ++ Env},
|
||||||
{apps, Apps},
|
{apps, Apps},
|
||||||
{conf,
|
{conf,
|
||||||
[{[listeners, Proto, default, enabled], false} || Proto <- [ssl, ws, wss]] ++
|
[{[listeners, Proto, default, enable], false} || Proto <- [ssl, ws, wss]] ++
|
||||||
[{[rpc, mode], async}]}
|
[{[rpc, mode], async}]}
|
||||||
],
|
],
|
||||||
Cluster = emqx_common_test_helpers:emqx_cluster(
|
Cluster = emqx_common_test_helpers:emqx_cluster(
|
||||||
|
|
|
@ -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)),
|
||||||
|
|
|
@ -206,9 +206,9 @@ cluster_specs() ->
|
||||||
{env, [{emqx, boot_modules, all}]},
|
{env, [{emqx, boot_modules, all}]},
|
||||||
{apps, []},
|
{apps, []},
|
||||||
{conf, [
|
{conf, [
|
||||||
{[listeners, ssl, default, enabled], false},
|
{[listeners, ssl, default, enable], false},
|
||||||
{[listeners, ws, default, enabled], false},
|
{[listeners, ws, default, enable], false},
|
||||||
{[listeners, wss, default, enabled], false}
|
{[listeners, wss, default, enable], false}
|
||||||
]}
|
]}
|
||||||
],
|
],
|
||||||
emqx_common_test_helpers:emqx_cluster(
|
emqx_common_test_helpers:emqx_cluster(
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Unify the listener switch to `enable`, while being compatible with the previous `enabled`.
|
Loading…
Reference in New Issue