diff --git a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.app.src b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.app.src index 6fbc0edde..52c69b21b 100644 --- a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.app.src +++ b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.app.src @@ -10,7 +10,10 @@ emqx_resource, emqtt ]}, - {env, []}, + {env, [ + {emqx_action_info_modules, [emqx_bridge_mqtt_pubsub_action_info]}, + {emqx_connector_info_modules, [emqx_bridge_mqtt_pubsub_connector_info]} + ]}, {modules, []}, {licenses, ["Apache 2.0"]}, {links, []} diff --git a/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_pubsub_connector_info.erl b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_pubsub_connector_info.erl new file mode 100644 index 000000000..9b64428cc --- /dev/null +++ b/apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt_pubsub_connector_info.erl @@ -0,0 +1,55 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 2020-2024 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_bridge_mqtt_pubsub_connector_info). + +-behaviour(emqx_connector_info). + +-export([ + type_name/0, + bridge_types/0, + resource_callback_module/0, + config_schema/0, + schema_module/0, + api_schema/1 +]). + +type_name() -> + mqtt. + +bridge_types() -> + [mqtt]. + +resource_callback_module() -> + emqx_bridge_mqtt_connector. + +config_schema() -> + {mqtt, + hoconsc:mk( + hoconsc:map(name, hoconsc:ref(emqx_bridge_mqtt_connector_schema, "config_connector")), + #{ + desc => <<"MQTT Connector Config">>, + required => false + } + )}. + +schema_module() -> + emqx_bridge_mqtt_connector_schema. + +api_schema(Method) -> + emqx_connector_schema:api_ref( + emqx_bridge_mqtt_connector_schema, <<"mqtt">>, Method ++ "_connector" + ). diff --git a/apps/emqx_connector/src/emqx_connector_info.erl b/apps/emqx_connector/src/emqx_connector_info.erl index c44c2b18c..67de571f9 100644 --- a/apps/emqx_connector/src/emqx_connector_info.erl +++ b/apps/emqx_connector/src/emqx_connector_info.erl @@ -81,7 +81,10 @@ hard_coded_connector_info_modules_ee() -> -endif. hard_coded_connector_info_modules_common() -> - [emqx_bridge_http_connector_info]. + [ + emqx_bridge_http_connector_info, + emqx_bridge_mqtt_pubsub_connector_info + ]. hard_coded_connector_info_modules() -> hard_coded_connector_info_modules_common() ++ hard_coded_connector_info_modules_ee(). diff --git a/apps/emqx_connector/src/emqx_connector_resource.erl b/apps/emqx_connector/src/emqx_connector_resource.erl index dec4ab2d7..9b109b732 100644 --- a/apps/emqx_connector/src/emqx_connector_resource.erl +++ b/apps/emqx_connector/src/emqx_connector_resource.erl @@ -88,10 +88,6 @@ connector_impl_module(ConnectorType) -> -endif. -connector_to_resource_type_ce(mqtt) -> - emqx_bridge_mqtt_connector; -% connector_to_resource_type_ce(mqtt_subscriber) -> -% emqx_bridge_mqtt_subscriber_connector; connector_to_resource_type_ce(ConnectorType) -> try emqx_connector_info:resource_callback_module(ConnectorType) diff --git a/apps/emqx_connector/src/schema/emqx_connector_schema.erl b/apps/emqx_connector/src/schema/emqx_connector_schema.erl index 01b6ec925..2af7cc52d 100644 --- a/apps/emqx_connector/src/schema/emqx_connector_schema.erl +++ b/apps/emqx_connector/src/schema/emqx_connector_schema.erl @@ -88,11 +88,7 @@ enterprise_fields_connectors() -> []. -endif. api_schemas(Method) -> - [ - %% We need to map the `type' field of a request (binary) to a - %% connector schema module. - api_ref(emqx_bridge_mqtt_connector_schema, <<"mqtt">>, Method ++ "_connector") - ]. + []. api_ref(Module, Type, Method) -> {Type, ref(Module, Method)}. @@ -111,11 +107,10 @@ examples(Method) -> -if(?EMQX_RELEASE_EDITION == ee). schema_modules() -> - [emqx_bridge_mqtt_connector_schema] ++ - emqx_connector_ee_schema:schema_modules() ++ connector_info_schema_modules(). + emqx_connector_ee_schema:schema_modules() ++ connector_info_schema_modules(). -else. schema_modules() -> - [emqx_bridge_mqtt_connector_schema] ++ connector_info_schema_modules(). + connector_info_schema_modules(). -endif. connector_info_schema_modules() -> @@ -127,8 +122,6 @@ connector_info_schema_modules() -> %% @doc Return old bridge(v1) and/or connector(v2) type %% from the latest connector type name. -connector_type_to_bridge_types(mqtt) -> - [mqtt]; connector_type_to_bridge_types(redis) -> [redis, redis_single, redis_sentinel, redis_cluster]; connector_type_to_bridge_types(rocketmq) -> @@ -505,16 +498,7 @@ roots() -> end. fields(connectors) -> - [ - {mqtt, - mk( - hoconsc:map(name, ref(emqx_bridge_mqtt_connector_schema, "config_connector")), - #{ - desc => <<"MQTT Publisher Connector Config">>, - required => false - } - )} - ] ++ enterprise_fields_connectors() ++ connector_info_fields_connectors(); + [] ++ enterprise_fields_connectors() ++ connector_info_fields_connectors(); fields("node_status") -> [ node_name(),