diff --git a/apps/emqx_connector/.gitignore b/apps/emqx_connector/.gitignore deleted file mode 100644 index f1c455451..000000000 --- a/apps/emqx_connector/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -.rebar3 -_* -.eunit -*.o -*.beam -*.plt -*.swp -*.swo -.erlang.cookie -ebin -log -erl_crash.dump -.rebar -logs -_build -.idea -*.iml -rebar3.crashdump -*~ diff --git a/apps/emqx_connector/README.md b/apps/emqx_connector/README.md deleted file mode 100644 index 879669f93..000000000 --- a/apps/emqx_connector/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# emqx_connector - -This application is a collection of `connectors`. - -A `connector` is a callback module of `emqx_resource` that maintains the data related to -external resources. Put all resource related callback modules in a single application is good as -we can put some util functions/modules here for reusing purpose. - -For example, a mysql connector is an emqx resource that maintains all the mysql connection -related parameters (configs) and the TCP connections to the mysql server. - -An mysql connector can be used as following: - -``` -(emqx@127.0.0.1)5> emqx_resource:list_instances_verbose(). -[#{config => - #{auto_reconnect => true,cacertfile => [],certfile => [], - database => "mqtt",keyfile => [],password => "public", - pool_size => 1, - server => {{127,0,0,1},3306}, - ssl => false,user => "root",verify => false}, - id => <<"mysql-abc">>,mod => emqx_connector_mysql, - state => #{poolname => 'mysql-abc'}, - status => started}] -(emqx@127.0.0.1)6> emqx_resource:query(<<"mysql-abc">>, {sql, <<"SELECT count(1)">>}). -{ok,[<<"count(1)">>],[[1]]} -``` diff --git a/apps/emqx_connector/etc/emqx_connector.conf b/apps/emqx_connector/etc/emqx_connector.conf deleted file mode 100644 index db4402d47..000000000 --- a/apps/emqx_connector/etc/emqx_connector.conf +++ /dev/null @@ -1,4 +0,0 @@ -##-------------------------------------------------------------------- -## EMQ X CONNECTOR Plugin -##-------------------------------------------------------------------- - diff --git a/apps/emqx_connector/priv/emqx_connector.schema b/apps/emqx_connector/priv/emqx_connector.schema deleted file mode 100644 index b8476c4d9..000000000 --- a/apps/emqx_connector/priv/emqx_connector.schema +++ /dev/null @@ -1,2 +0,0 @@ -%%-*- mode: erlang -*- -%% emqx_connector config mapping diff --git a/apps/emqx_connector/rebar.config b/apps/emqx_connector/rebar.config deleted file mode 100644 index 53b5c63e8..000000000 --- a/apps/emqx_connector/rebar.config +++ /dev/null @@ -1,13 +0,0 @@ -{erl_opts, [ - nowarn_unused_import, - debug_info -]}. - -{deps, [ - {mysql, {git, "https://github.com/emqx/mysql-otp", {tag, "1.7.1"}}} -]}. - -{shell, [ - % {config, "config/sys.config"}, - {apps, [emqx_connector]} -]}. diff --git a/apps/emqx_connector/src/emqx_connector.app.src b/apps/emqx_connector/src/emqx_connector.app.src deleted file mode 100644 index a821b8f13..000000000 --- a/apps/emqx_connector/src/emqx_connector.app.src +++ /dev/null @@ -1,17 +0,0 @@ -{application, emqx_connector, - [{description, "An OTP application"}, - {vsn, "0.1.0"}, - {registered, []}, - {mod, {emqx_connector_app, []}}, - {applications, - [kernel, - stdlib, - emqx_resource, - ecpool - ]}, - {env,[]}, - {modules, []}, - - {licenses, ["Apache 2.0"]}, - {links, []} - ]}. diff --git a/apps/emqx_connector/src/emqx_connector.erl b/apps/emqx_connector/src/emqx_connector.erl deleted file mode 100644 index dd0359348..000000000 --- a/apps/emqx_connector/src/emqx_connector.erl +++ /dev/null @@ -1,16 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%%-------------------------------------------------------------------- --module(emqx_connector). diff --git a/apps/emqx_connector/src/emqx_connector_app.erl b/apps/emqx_connector/src/emqx_connector_app.erl deleted file mode 100644 index 4bbad75cf..000000000 --- a/apps/emqx_connector/src/emqx_connector_app.erl +++ /dev/null @@ -1,31 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%%-------------------------------------------------------------------- - --module(emqx_connector_app). - --behaviour(application). - --emqx_plugin(?MODULE). - --export([start/2, stop/1]). - -start(_StartType, _StartArgs) -> - emqx_connector_sup:start_link(). - -stop(_State) -> - ok. - -%% internal functions diff --git a/apps/emqx_connector/src/emqx_connector_sup.erl b/apps/emqx_connector/src/emqx_connector_sup.erl deleted file mode 100644 index 603b9a8ad..000000000 --- a/apps/emqx_connector/src/emqx_connector_sup.erl +++ /dev/null @@ -1,36 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%%-------------------------------------------------------------------- --module(emqx_connector_sup). - --behaviour(supervisor). - --export([start_link/0]). - --export([init/1]). - --define(SERVER, ?MODULE). - -start_link() -> - supervisor:start_link({local, ?SERVER}, ?MODULE, []). - -init([]) -> - SupFlags = #{strategy => one_for_all, - intensity => 0, - period => 1}, - ChildSpecs = [], - {ok, {SupFlags, ChildSpecs}}. - -%% internal functions diff --git a/apps/emqx_connector/include/emqx_connector.hrl b/apps/emqx_data_bridge/include/emqx_data_bridge.hrl similarity index 100% rename from apps/emqx_connector/include/emqx_connector.hrl rename to apps/emqx_data_bridge/include/emqx_data_bridge.hrl diff --git a/apps/emqx_data_bridge/priv/emqx_data_bridge.schema b/apps/emqx_data_bridge/priv/emqx_data_bridge.schema deleted file mode 100644 index c9cb3f2c0..000000000 --- a/apps/emqx_data_bridge/priv/emqx_data_bridge.schema +++ /dev/null @@ -1,16 +0,0 @@ -%%-*- mode: erlang -*- -%% emqx_data_bridge config mapping - -{mapping, "emqx_data_bridge.bridges", "emqx_data_bridge.bridges", [ - {default, []}, - {datatype, string} -]}. - -% fields("emqx_data_bridge") -> -% [ -% {bridges, -% [fun(mapping) -> "emqx_data_bridge.bridges"; -% (type) -> list(); -% (_) -> undefined -% end]} -% ] \ No newline at end of file diff --git a/apps/emqx_data_bridge/rebar.config b/apps/emqx_data_bridge/rebar.config index cf4cfcf1b..2778ec974 100644 --- a/apps/emqx_data_bridge/rebar.config +++ b/apps/emqx_data_bridge/rebar.config @@ -1,5 +1,6 @@ {erl_opts, [debug_info]}. {deps, []}. +% {extra_src_dirs, [{"src", [{recursive, true}]}]}. {shell, [ % {config, "config/sys.config"}, diff --git a/apps/emqx_connector/src/emqx_connector_ldap.erl b/apps/emqx_data_bridge/src/connector/emqx_connector_ldap.erl similarity index 99% rename from apps/emqx_connector/src/emqx_connector_ldap.erl rename to apps/emqx_data_bridge/src/connector/emqx_connector_ldap.erl index 3b0af5aa7..322bce1ef 100644 --- a/apps/emqx_connector/src/emqx_connector_ldap.erl +++ b/apps/emqx_data_bridge/src/connector/emqx_connector_ldap.erl @@ -15,7 +15,7 @@ %%-------------------------------------------------------------------- -module(emqx_connector_ldap). --include("emqx_connector.hrl"). +-include("emqx_data_bridge.hrl"). -include_lib("typerefl/include/types.hrl"). -include_lib("emqx_resource/include/emqx_resource_behaviour.hrl"). diff --git a/apps/emqx_connector/src/emqx_connector_mongo.erl b/apps/emqx_data_bridge/src/connector/emqx_connector_mongo.erl similarity index 99% rename from apps/emqx_connector/src/emqx_connector_mongo.erl rename to apps/emqx_data_bridge/src/connector/emqx_connector_mongo.erl index 26a36dd0a..9e22e5ac5 100644 --- a/apps/emqx_connector/src/emqx_connector_mongo.erl +++ b/apps/emqx_data_bridge/src/connector/emqx_connector_mongo.erl @@ -15,7 +15,7 @@ %%-------------------------------------------------------------------- -module(emqx_connector_mongo). --include("emqx_connector.hrl"). +-include("emqx_data_bridge.hrl"). -include_lib("typerefl/include/types.hrl"). -include_lib("emqx_resource/include/emqx_resource_behaviour.hrl"). diff --git a/apps/emqx_connector/src/emqx_connector_mysql.erl b/apps/emqx_data_bridge/src/connector/emqx_connector_mysql.erl similarity index 100% rename from apps/emqx_connector/src/emqx_connector_mysql.erl rename to apps/emqx_data_bridge/src/connector/emqx_connector_mysql.erl diff --git a/apps/emqx_connector/src/emqx_connector_pgsql.erl b/apps/emqx_data_bridge/src/connector/emqx_connector_pgsql.erl similarity index 100% rename from apps/emqx_connector/src/emqx_connector_pgsql.erl rename to apps/emqx_data_bridge/src/connector/emqx_connector_pgsql.erl diff --git a/apps/emqx_connector/src/emqx_connector_redis.erl b/apps/emqx_data_bridge/src/connector/emqx_connector_redis.erl similarity index 99% rename from apps/emqx_connector/src/emqx_connector_redis.erl rename to apps/emqx_data_bridge/src/connector/emqx_connector_redis.erl index 3eebbcf87..1037afede 100644 --- a/apps/emqx_connector/src/emqx_connector_redis.erl +++ b/apps/emqx_data_bridge/src/connector/emqx_connector_redis.erl @@ -15,7 +15,7 @@ %%-------------------------------------------------------------------- -module(emqx_connector_redis). --include("emqx_connector.hrl"). +-include("emqx_data_bridge.hrl"). -include_lib("typerefl/include/types.hrl"). -include_lib("emqx_resource/include/emqx_resource_behaviour.hrl"). diff --git a/apps/emqx_connector/src/emqx_connector_schema_lib.erl b/apps/emqx_data_bridge/src/connector/emqx_connector_schema_lib.erl similarity index 99% rename from apps/emqx_connector/src/emqx_connector_schema_lib.erl rename to apps/emqx_data_bridge/src/connector/emqx_connector_schema_lib.erl index 03572d91d..aaacd0e80 100644 --- a/apps/emqx_connector/src/emqx_connector_schema_lib.erl +++ b/apps/emqx_data_bridge/src/connector/emqx_connector_schema_lib.erl @@ -15,7 +15,7 @@ %%-------------------------------------------------------------------- -module(emqx_connector_schema_lib). --include("emqx_connector.hrl"). +-include("emqx_data_bridge.hrl"). -include_lib("typerefl/include/types.hrl"). -export([ relational_db_fields/0 diff --git a/apps/emqx_data_bridge/src/emqx_data_bridge.app.src b/apps/emqx_data_bridge/src/emqx_data_bridge.app.src index 360511d9b..edfcd4a9d 100644 --- a/apps/emqx_data_bridge/src/emqx_data_bridge.app.src +++ b/apps/emqx_data_bridge/src/emqx_data_bridge.app.src @@ -5,7 +5,8 @@ {mod, {emqx_data_bridge_app, []}}, {applications, [kernel, - stdlib + stdlib, + ecpool ]}, {env,[]}, {modules, []}, diff --git a/apps/emqx_data_bridge/src/emqx_data_bridge.erl b/apps/emqx_data_bridge/src/emqx_data_bridge.erl index 5877cd3dd..54a228763 100644 --- a/apps/emqx_data_bridge/src/emqx_data_bridge.erl +++ b/apps/emqx_data_bridge/src/emqx_data_bridge.erl @@ -25,8 +25,9 @@ ]). load_bridges() -> - Bridges = proplists:get_value(bridges, - application:get_all_env(emqx_data_bridge), []), + ConfFile = filename:join([emqx:get_env(plugins_etc_dir), ?MODULE]) ++ ".conf", + {ok, #{<<"emqx_data_bridge">> := RawConfig}} = hocon:load(ConfFile), + Bridges = maps:get(<<"bridges">>, RawConfig, []), emqx_data_bridge_monitor:ensure_all_started(Bridges). resource_type(<<"mysql">>) -> emqx_connector_mysql; diff --git a/apps/emqx_resource/priv/emqx_resource.schema b/apps/emqx_resource/priv/emqx_resource.schema deleted file mode 100644 index 8246dc6a7..000000000 --- a/apps/emqx_resource/priv/emqx_resource.schema +++ /dev/null @@ -1,2 +0,0 @@ -%%-*- mode: erlang -*- -%% emqx-resource config mapping diff --git a/data/loaded_plugins.tmpl b/data/loaded_plugins.tmpl index 5ac46e0e3..d0dac7fe1 100644 --- a/data/loaded_plugins.tmpl +++ b/data/loaded_plugins.tmpl @@ -5,7 +5,4 @@ {emqx_retainer, {{enable_plugin_emqx_retainer}}}. {emqx_telemetry, {{enable_plugin_emqx_telemetry}}}. {emqx_rule_engine, {{enable_plugin_emqx_rule_engine}}}. -{emqx_resource, {{enable_plugin_emqx_resource}}}. -{emqx_connector, {{enable_plugin_emqx_connector}}}. -{emqx_data_bridge, {{enable_plugin_emqx_data_bridge}}}. {emqx_bridge_mqtt, {{enable_plugin_emqx_bridge_mqtt}}}. diff --git a/rebar.config.erl b/rebar.config.erl index 0248e6dab..45baf0ea1 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -186,9 +186,6 @@ overlay_vars_rel(RelType) -> end, [ {enable_plugin_emqx_rule_engine, RelType =:= cloud} , {enable_plugin_emqx_bridge_mqtt, RelType =:= edge} - , {enable_plugin_emqx_resource, true} - , {enable_plugin_emqx_connector, true} - , {enable_plugin_emqx_data_bridge, true} , {enable_plugin_emqx_modules, false} %% modules is not a plugin in ce , {enable_plugin_emqx_recon, true} , {enable_plugin_emqx_retainer, true} @@ -247,6 +244,8 @@ relx_apps(ReleaseType) -> , {emqx_plugin_libs, load} , observer_cli , emqx_http_lib + , emqx_resource + , emqx_data_bridge ] ++ [emqx_modules || not is_enterprise()] ++ [emqx_license || is_enterprise()] @@ -284,10 +283,8 @@ relx_plugin_apps(ReleaseType) -> , emqx_auth_mnesia , emqx_web_hook , emqx_recon - , emqx_resource - , emqx_connector - , emqx_data_bridge , emqx_rule_engine + , emqx_data_bridge , emqx_sasl ] ++ [emqx_telemetry || not is_enterprise()]