From f9b211cce61362c61ec6ee4b154601f807d2399b Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 21 Oct 2021 22:54:52 +0200 Subject: [PATCH 1/4] chore: pin hocon 0.20.5 for two changes: default string values are filled with binary() instead of [integer()] better reference links in config document --- apps/emqx/rebar.config | 2 +- rebar.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/emqx/rebar.config b/apps/emqx/rebar.config index 4ea0b06be..61d5717d9 100644 --- a/apps/emqx/rebar.config +++ b/apps/emqx/rebar.config @@ -17,7 +17,7 @@ , {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.0"}}} , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.11.1"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} - , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.3"}}} + , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.5"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.14.1"}}} diff --git a/rebar.config b/rebar.config index 650b8ca9f..4beee1e86 100644 --- a/rebar.config +++ b/rebar.config @@ -61,7 +61,7 @@ , {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x , {getopt, "1.0.2"} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.14.1"}}} - , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.3"}}} + , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.5"}}} , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.4.1"}}} , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}} , {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.1"}}} From b03b0717ce4eb41caaa1214920e55fa48412ae84 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 21 Oct 2021 22:59:59 +0200 Subject: [PATCH 2/4] docs: authenticator_config ref link to the struct --- apps/emqx/src/emqx_schema.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index 118cea5df..a80be2424 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -1358,9 +1358,9 @@ authentication(Desc) -> #{ type => hoconsc:lazy(hoconsc:union([typerefl:map(), hoconsc:array(typerefl:map())])) , desc => iolist_to_binary([Desc, "
", """ Authentication can be one single authenticator instance or a chain of authenticators as an array. -The when authenticating a login (username, client ID, etc.) the authenticators are checked +When authenticating a login (username, client ID, etc.) the authenticators are checked in the configured order.
EMQ X comes with a set of pre-built autenticators, for more details, see -authenticator_config. +autenticator_config """]) }. From aa6053291ed0c09f03f410add017b221946a03e1 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 21 Oct 2021 23:02:27 +0200 Subject: [PATCH 3/4] fix(schema): add roots for emqx_zone_schema emqx_zone_schema is never used at root level, but for config doc generation, it needs the roots. --- apps/emqx/src/emqx_schema.erl | 5 +---- apps/emqx/src/emqx_zone_schema.erl | 7 ++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index a80be2424..2d71a1d69 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -331,10 +331,7 @@ fields("mqtt") -> ]; fields("zone") -> - Fields = ["mqtt", "stats", "flapping_detect", "force_shutdown", - "conn_congestion", "rate_limit", "quota", "force_gc", - "overload_protection" - ], + Fields = emqx_zone_schema:roots(), [{F, ref(emqx_zone_schema, F)} || F <- Fields]; fields("rate_limit") -> diff --git a/apps/emqx/src/emqx_zone_schema.erl b/apps/emqx/src/emqx_zone_schema.erl index 013ffb22f..1d24f9481 100644 --- a/apps/emqx/src/emqx_zone_schema.erl +++ b/apps/emqx/src/emqx_zone_schema.erl @@ -20,7 +20,12 @@ namespace() -> zone. -roots() -> []. +%% this shcema module is not used at root level. +%% roots are added only for document generation. +roots() -> ["mqtt", "stats", "flapping_detect", "force_shutdown", + "conn_congestion", "rate_limit", "quota", "force_gc", + "overload_protection" + ]. %% zone schemas are clones from the same name from root level %% only not allowed to have default values. From 0937c8163247e2940815b3fe47451348b0f5222b Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Fri, 22 Oct 2021 07:46:57 +0200 Subject: [PATCH 4/4] test: fix emqx_config_SUITE --- apps/emqx/test/emqx_config_SUITE.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/emqx/test/emqx_config_SUITE.erl b/apps/emqx/test/emqx_config_SUITE.erl index 88585492b..6b3022cae 100644 --- a/apps/emqx/test/emqx_config_SUITE.erl +++ b/apps/emqx/test/emqx_config_SUITE.erl @@ -36,6 +36,7 @@ t_fill_default_values(_) -> <<"perf">> => #{}, <<"route_batch_clean">> => false} }, + WithDefaults = emqx_config:fill_defaults(Conf), ?assertMatch(#{<<"broker">> := #{<<"enable_session_registry">> := true, <<"perf">> := @@ -45,6 +46,8 @@ t_fill_default_values(_) -> <<"session_locking_strategy">> := quorum, <<"shared_dispatch_ack_enabled">> := false, <<"shared_subscription_strategy">> := round_robin, - <<"sys_heartbeat_interval">> := "30s", - <<"sys_msg_interval">> := "1m"}}, - emqx_config:fill_defaults(Conf)). + <<"sys_heartbeat_interval">> := <<"30s">>, + <<"sys_msg_interval">> := <<"1m">>}}, WithDefaults), + %% ensure JSON compatible + _ = emqx_json:encode(WithDefaults), + ok.