refactor(confluent connector): to use emqx_connector_info

This commit refactors the emqx_bridge_confluent to use the
emqx_connector_info behavior. The emqx_bridge_confluent related
information can thus be removed from emqx_connector_ee_schema and
emqx_connector_schema.
This commit is contained in:
Kjell Winblad 2024-03-18 17:16:18 +01:00
parent 795b668c4f
commit 76d32b6e97
5 changed files with 59 additions and 21 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_confluent, [
{description, "EMQX Enterprise Confluent Connector and Action"},
{vsn, "0.1.1"},
{vsn, "0.1.2"},
{registered, []},
{applications, [
kernel,
@ -9,7 +9,10 @@
telemetry,
wolff
]},
{env, [{emqx_action_info_modules, [emqx_bridge_confluent_producer_action_info]}]},
{env, [
{emqx_action_info_modules, [emqx_bridge_confluent_producer_action_info]},
{emqx_connector_info_modules, [emqx_bridge_confluent_producer_connector_info]}
]},
{modules, []},
{links, []}
]}.

View File

@ -0,0 +1,52 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2022-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
%%--------------------------------------------------------------------
-module(emqx_bridge_confluent_producer_connector_info).
-behaviour(emqx_connector_info).
%% API exports.
-export([
type_name/0,
bridge_types/0,
resource_callback_module/0,
config_transform_module/0,
config_schema/0,
schema_module/0,
api_schema/1
]).
%%--------------------------------------------------------------------
%% API Functions
%%--------------------------------------------------------------------
type_name() ->
confluent_producer.
bridge_types() ->
[confluent_producer].
resource_callback_module() ->
emqx_bridge_kafka_impl_producer.
config_transform_module() ->
emqx_bridge_confluent_producer.
config_schema() ->
{confluent_producer,
hoconsc:mk(
hoconsc:map(name, hoconsc:ref(emqx_bridge_confluent_producer, "config_connector")),
#{
desc => <<"Confluent Connector Config">>,
required => false
}
)}.
schema_module() ->
emqx_bridge_confluent_producer.
api_schema(Method) ->
emqx_connector_schema:api_ref(
emqx_bridge_confluent_producer, <<"confluent_producer">>, Method ++ "_connector"
).

View File

@ -57,7 +57,8 @@
hard_coded_connector_info_modules_ee() ->
[
emqx_bridge_dynamo_connector_info,
emqx_bridge_azure_event_hub_connector_info
emqx_bridge_azure_event_hub_connector_info,
emqx_bridge_confluent_producer_connector_info
].
-else.
hard_coded_connector_info_modules_ee() ->

View File

@ -21,8 +21,6 @@
resource_type(Type) when is_binary(Type) ->
resource_type(binary_to_atom(Type, utf8));
resource_type(confluent_producer) ->
emqx_bridge_kafka_impl_producer;
resource_type(gcp_pubsub_consumer) ->
emqx_bridge_gcp_pubsub_impl_consumer;
resource_type(gcp_pubsub_producer) ->
@ -90,8 +88,6 @@ resource_type(Type) ->
%% For connectors that need to override connector configurations.
connector_impl_module(ConnectorType) when is_binary(ConnectorType) ->
connector_impl_module(binary_to_atom(ConnectorType, utf8));
connector_impl_module(confluent_producer) ->
emqx_bridge_confluent_producer;
connector_impl_module(iotdb) ->
emqx_bridge_iotdb_connector;
connector_impl_module(elasticsearch) ->
@ -114,14 +110,6 @@ fields(connectors) ->
connector_structs() ->
[
{confluent_producer,
mk(
hoconsc:map(name, ref(emqx_bridge_confluent_producer, "config_connector")),
#{
desc => <<"Confluent Connector Config">>,
required => false
}
)},
{gcp_pubsub_consumer,
mk(
hoconsc:map(name, ref(emqx_bridge_gcp_pubsub_consumer_schema, "config_connector")),
@ -351,7 +339,6 @@ connector_structs() ->
schema_modules() ->
[
emqx_bridge_confluent_producer,
emqx_bridge_gcp_pubsub_consumer_schema,
emqx_bridge_gcp_pubsub_producer_schema,
emqx_bridge_hstreamdb,
@ -386,9 +373,6 @@ api_schemas(Method) ->
[
%% We need to map the `type' field of a request (binary) to a
%% connector schema module.
api_ref(
emqx_bridge_confluent_producer, <<"confluent_producer">>, Method ++ "_connector"
),
api_ref(
emqx_bridge_gcp_pubsub_consumer_schema,
<<"gcp_pubsub_consumer">>,

View File

@ -130,8 +130,6 @@ connector_info_schema_modules() ->
%% from the latest connector type name.
connector_type_to_bridge_types(http) ->
[webhook, http];
connector_type_to_bridge_types(confluent_producer) ->
[confluent_producer];
connector_type_to_bridge_types(gcp_pubsub_consumer) ->
[gcp_pubsub_consumer];
connector_type_to_bridge_types(gcp_pubsub_producer) ->