Explorar el Código

chore(statsd): update statsd conf root

Turtle hace 4 años
padre
commit
4afae79be9

+ 2 - 2
apps/emqx/src/emqx_schema.erl

@@ -72,7 +72,7 @@
 -export([ssl/1]).
 
 %% will be used by emqx_ct_helper to find the dependent apps
--export([includes/0]).
+-export([includes/0, extra_schema_fields/1]).
 
 structs() -> ["cluster", "node", "rpc", "log",
               "zones", "listeners", "broker",
@@ -485,7 +485,7 @@ fields("alarm") ->
     ];
 
 fields(FieldName) ->
-    extra_schema_fields(FieldName).
+    ?MODULE:extra_schema_fields(FieldName).
 
 -ifndef(EMQX_EXT_SCHEMAS).
 %% Function extra_schema_fields/1 only terminates with explicit exception

+ 1 - 0
apps/emqx_authz/test/emqx_authz_api_SUITE.erl

@@ -46,6 +46,7 @@ init_per_suite(Config) ->
     %% important! let emqx_schema include the current app!
     meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
+    meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
 
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
     %create_default_app(),

+ 1 - 0
apps/emqx_authz/test/emqx_authz_http_SUITE.erl

@@ -32,6 +32,7 @@ init_per_suite(Config) ->
     %% important! let emqx_schema include the current app!
     meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
+    meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
 
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),

+ 1 - 0
apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl

@@ -35,6 +35,7 @@ init_per_suite(Config) ->
     %% important! let emqx_schema include the current app!
     meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
+    meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
 
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
     ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),

+ 1 - 0
apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl

@@ -32,6 +32,7 @@ init_per_suite(Config) ->
     %% important! let emqx_schema include the current app!
     meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
+    meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
 
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),

+ 1 - 0
apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl

@@ -32,6 +32,7 @@ init_per_suite(Config) ->
     %% important! let emqx_schema include the current app!
     meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
+    meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
 
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),

+ 1 - 0
apps/emqx_authz/test/emqx_authz_redis_SUITE.erl

@@ -32,6 +32,7 @@ init_per_suite(Config) ->
     %% important! let emqx_schema include the current app!
     meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
+    meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
 
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),

+ 1 - 1
apps/emqx_statsd/etc/emqx_statsd.conf

@@ -2,7 +2,7 @@
 ## Statsd for EMQ X
 ##--------------------------------------------------------------------
 
-emqx_statsd:{
+statsd:{
     enable: true
     server: "127.0.0.1:8125"
     sample_time_interval: "10s"

+ 0 - 1
apps/emqx_statsd/src/emqx_statsd.app.src

@@ -10,7 +10,6 @@
    ]},
   {env,[]},
   {modules, []},
-
   {licenses, ["Apache 2.0"]},
   {links, []}
  ]}.

+ 4 - 4
apps/emqx_statsd/src/emqx_statsd_api.erl

@@ -84,23 +84,23 @@ statsd_api() ->
     [{"/statsd", Metadata, statsd}].
 
 statsd(get, _Request) ->
-    Response = emqx_config:get_raw([<<"emqx_statsd">>], #{}),
+    Response = emqx_config:get_raw([<<"statsd">>], #{}),
     {200, Response};
 
 statsd(put, Request) ->
     {ok, Body, _} = cowboy_req:read_body(Request),
     Params = emqx_json:decode(Body, [return_maps]),
     Enable = maps:get(<<"enable">>, Params),
-    ok = emqx_config:update([emqx_statsd], Params),
+    ok = emqx_config:update([statsd], Params),
     enable_statsd(Enable).
 
 enable_statsd(true) ->
     ok = emqx_statsd_sup:stop_child(?APP),
-    emqx_statsd_sup:start_child(?APP, emqx_config:get([?APP], #{})),
+    emqx_statsd_sup:start_child(?APP, emqx_config:get([statsd], #{})),
     {200};
 enable_statsd(false) ->
     _ = emqx_statsd_sup:stop_child(?APP),
     {200}.
 
 get_raw(Key, Def) ->
-    emqx_config:get_raw([<<"emqx_statsd">>]++ [Key], Def).
+    emqx_config:get_raw([<<"statsd">>]++ [Key], Def).

+ 2 - 2
apps/emqx_statsd/src/emqx_statsd_app.erl

@@ -32,9 +32,9 @@ stop(_) ->
     ok.
 
 maybe_enable_statsd() ->
-    case emqx_config:get([?APP, enable], false) of
+    case emqx_config:get([statsd, enable], false) of
         true ->
-            emqx_statsd_sup:start_child(?APP, emqx_config:get([?APP], #{}));
+            emqx_statsd_sup:start_child(?APP, emqx_config:get([statsd], #{}));
         false ->
             ok
     end.

+ 2 - 2
apps/emqx_statsd/src/emqx_statsd_schema.erl

@@ -11,9 +11,9 @@
 
 -typerefl_from_string({ip_port/0, emqx_statsd_schema, to_ip_port}).
 
-structs() -> ["emqx_statsd"].
+structs() -> ["statsd"].
 
-fields("emqx_statsd") ->
+fields("statsd") ->
     [ {enable, emqx_schema:t(boolean(), undefined, false)}
     , {server, fun server/1}
     , {sample_time_interval, fun duration_ms/1}

+ 1 - 1
extension_schemas.config

@@ -5,7 +5,6 @@
 %%
 [ {"emqx_data_bridge", emqx_data_bridge_schema}
 , {"emqx_retainer", emqx_retainer_schema}
-, {"emqx_statsd", emqx_statsd_schema}
 , {"emqx_authn", emqx_authn_schema}
 , {"emqx_authz", emqx_authz_schema}
 , {"emqx_bridge_mqtt", emqx_bridge_mqtt_schema}
@@ -14,4 +13,5 @@
 , {"emqx_dashboard", emqx_dashboard_schema}
 , {"emqx_gateway", emqx_gateway_schema}
 , {"emqx_prometheus", emqx_prometheus_schema}
+, {"statsd", emqx_statsd_schema}
 ].

+ 3 - 2
rebar.config.erl

@@ -152,6 +152,7 @@ prod_overrides() ->
     [{add, [ {erl_opts, [deterministic]}]}].
 
 profiles() ->
+    CommonCompileOpts = lists:keydelete('EMQX_EXT_SCHEMAS', 2, common_compile_opts()),
     Vsn = get_vsn(),
     [ {'emqx',          [ {erl_opts, prod_compile_opts()}
                         , {relx, relx(Vsn, cloud, bin)}
@@ -169,10 +170,10 @@ profiles() ->
                         , {relx, relx(Vsn, edge, pkg)}
                         , {overrides, prod_overrides()}
                         ]}
-    , {check,           [ {erl_opts, common_compile_opts()}
+    , {check,           [ {erl_opts, CommonCompileOpts}
                         ]}
     , {test,            [ {deps, test_deps()}
-                        , {erl_opts, common_compile_opts() ++ erl_opts_i()}
+                        , {erl_opts, CommonCompileOpts ++ erl_opts_i() }
                         , {extra_src_dirs, [{"test", [{recursive,true}]}]}
                         ]}
     ] ++ ee_profiles(Vsn).