Explorar o código

fix(emqx_resource): fix schema schema definition

Zaiming Shi %!s(int64=4) %!d(string=hai) anos
pai
achega
9a78f812e1

+ 0 - 1
apps/emqx/src/emqx_schema.erl

@@ -1,6 +1,5 @@
 -module(emqx_schema).
 
-% tmp
 -dialyzer(no_return).
 -dialyzer(no_match).
 -dialyzer(no_contracts).

+ 6 - 1
apps/emqx_connector/src/emqx_connector_mysql.erl

@@ -18,7 +18,8 @@
 -include_lib("typerefl/include/types.hrl").
 -include_lib("emqx_resource/include/emqx_resource_behaviour.hrl").
 
--export([ schema/0
+-export([ structs/0
+        , fields/1
         ]).
 
 %% callbacks of behaviour emqx_resource
@@ -34,6 +35,10 @@
 -export([do_health_check/1]).
 
 %%=====================================================================
+
+structs() -> ["config"].
+fields("config") -> schema().
+
 schema() ->
     emqx_connector_schema_lib:relational_db_fields() ++
     emqx_connector_schema_lib:ssl_fields().

+ 1 - 16
apps/emqx_resource/src/emqx_resource_schema.erl

@@ -18,21 +18,6 @@
 
 -export([check/2]).
 
--export([structs/0, fields/1]).
-
--behaviour(hocon_schema).
-
 check(SchemaMod, Conf) ->
-    _ = erlang:erase(res_schema_mod),
-    erlang:put(res_schema_mod, SchemaMod),
-    hocon_schema:check(?MODULE, Conf).
-
-structs() -> ["config"].
+    hocon_schema:check(SchemaMod, Conf, #{nullable => false}).
 
-fields("config") ->
-    [fun(type) -> "schema";
-        (_) -> undefined
-     end];
-fields("schema") ->
-    SchemaMod = erlang:get(res_schema_mod),
-    SchemaMod:schema().