refactor(oracle connector): to use emqx_connector_info
This commit refactors the oracle connector to use the `emqx_connector_info` behavior.
This commit is contained in:
parent
df8c7152fc
commit
c1e6092013
|
@ -8,7 +8,10 @@
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_oracle
|
emqx_oracle
|
||||||
]},
|
]},
|
||||||
{env, [{emqx_action_info_modules, [emqx_bridge_oracle_action_info]}]},
|
{env, [
|
||||||
|
{emqx_action_info_modules, [emqx_bridge_oracle_action_info]},
|
||||||
|
{emqx_connector_info_modules, [emqx_bridge_oracle_connector_info]}
|
||||||
|
]},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
|
|
||||||
{links, []}
|
{links, []}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2022-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(emqx_bridge_oracle_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() ->
|
||||||
|
oracle.
|
||||||
|
|
||||||
|
bridge_types() ->
|
||||||
|
[oracle].
|
||||||
|
|
||||||
|
resource_callback_module() ->
|
||||||
|
emqx_oracle.
|
||||||
|
|
||||||
|
config_schema() ->
|
||||||
|
{oracle,
|
||||||
|
hoconsc:mk(
|
||||||
|
hoconsc:map(name, hoconsc:ref(emqx_bridge_oracle, "config_connector")),
|
||||||
|
#{
|
||||||
|
desc => <<"Oracle Connector Config">>,
|
||||||
|
required => false,
|
||||||
|
validator => fun emqx_bridge_oracle:config_validator/1
|
||||||
|
}
|
||||||
|
)}.
|
||||||
|
|
||||||
|
schema_module() ->
|
||||||
|
emqx_bridge_oracle.
|
||||||
|
|
||||||
|
api_schema(Method) ->
|
||||||
|
emqx_connector_schema:api_ref(
|
||||||
|
emqx_bridge_oracle, <<"oracle">>, Method ++ "_connector"
|
||||||
|
).
|
|
@ -68,7 +68,8 @@ hard_coded_connector_info_modules_ee() ->
|
||||||
emqx_bridge_matrix_connector_info,
|
emqx_bridge_matrix_connector_info,
|
||||||
emqx_bridge_pgsql_connector_info,
|
emqx_bridge_pgsql_connector_info,
|
||||||
emqx_bridge_timescale_connector_info,
|
emqx_bridge_timescale_connector_info,
|
||||||
emqx_bridge_mongodb_connector_info
|
emqx_bridge_mongodb_connector_info,
|
||||||
|
emqx_bridge_oracle_connector_info
|
||||||
].
|
].
|
||||||
-else.
|
-else.
|
||||||
hard_coded_connector_info_modules_ee() ->
|
hard_coded_connector_info_modules_ee() ->
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
resource_type(Type) when is_binary(Type) ->
|
resource_type(Type) when is_binary(Type) ->
|
||||||
resource_type(binary_to_atom(Type, utf8));
|
resource_type(binary_to_atom(Type, utf8));
|
||||||
resource_type(oracle) ->
|
|
||||||
emqx_oracle;
|
|
||||||
resource_type(influxdb) ->
|
resource_type(influxdb) ->
|
||||||
emqx_bridge_influxdb_connector;
|
emqx_bridge_influxdb_connector;
|
||||||
resource_type(cassandra) ->
|
resource_type(cassandra) ->
|
||||||
|
@ -85,15 +83,6 @@ fields(connectors) ->
|
||||||
|
|
||||||
connector_structs() ->
|
connector_structs() ->
|
||||||
[
|
[
|
||||||
{oracle,
|
|
||||||
mk(
|
|
||||||
hoconsc:map(name, ref(emqx_bridge_oracle, "config_connector")),
|
|
||||||
#{
|
|
||||||
desc => <<"Oracle Connector Config">>,
|
|
||||||
required => false,
|
|
||||||
validator => fun emqx_bridge_oracle:config_validator/1
|
|
||||||
}
|
|
||||||
)},
|
|
||||||
{influxdb,
|
{influxdb,
|
||||||
mk(
|
mk(
|
||||||
hoconsc:map(name, ref(emqx_bridge_influxdb, "config_connector")),
|
hoconsc:map(name, ref(emqx_bridge_influxdb, "config_connector")),
|
||||||
|
@ -234,7 +223,6 @@ connector_structs() ->
|
||||||
|
|
||||||
schema_modules() ->
|
schema_modules() ->
|
||||||
[
|
[
|
||||||
emqx_bridge_oracle,
|
|
||||||
emqx_bridge_influxdb,
|
emqx_bridge_influxdb,
|
||||||
emqx_bridge_cassandra,
|
emqx_bridge_cassandra,
|
||||||
emqx_bridge_clickhouse,
|
emqx_bridge_clickhouse,
|
||||||
|
@ -259,7 +247,6 @@ api_schemas(Method) ->
|
||||||
[
|
[
|
||||||
%% We need to map the `type' field of a request (binary) to a
|
%% We need to map the `type' field of a request (binary) to a
|
||||||
%% connector schema module.
|
%% connector schema module.
|
||||||
api_ref(emqx_bridge_oracle, <<"oracle">>, Method ++ "_connector"),
|
|
||||||
api_ref(emqx_bridge_influxdb, <<"influxdb">>, Method ++ "_connector"),
|
api_ref(emqx_bridge_influxdb, <<"influxdb">>, Method ++ "_connector"),
|
||||||
api_ref(emqx_bridge_cassandra, <<"cassandra">>, Method ++ "_connector"),
|
api_ref(emqx_bridge_cassandra, <<"cassandra">>, Method ++ "_connector"),
|
||||||
api_ref(emqx_bridge_clickhouse, <<"clickhouse">>, Method ++ "_connector"),
|
api_ref(emqx_bridge_clickhouse, <<"clickhouse">>, Method ++ "_connector"),
|
||||||
|
|
|
@ -127,8 +127,6 @@ connector_info_schema_modules() ->
|
||||||
|
|
||||||
%% @doc Return old bridge(v1) and/or connector(v2) type
|
%% @doc Return old bridge(v1) and/or connector(v2) type
|
||||||
%% from the latest connector type name.
|
%% from the latest connector type name.
|
||||||
connector_type_to_bridge_types(oracle) ->
|
|
||||||
[oracle];
|
|
||||||
connector_type_to_bridge_types(influxdb) ->
|
connector_type_to_bridge_types(influxdb) ->
|
||||||
[influxdb, influxdb_api_v1, influxdb_api_v2];
|
[influxdb, influxdb_api_v1, influxdb_api_v2];
|
||||||
connector_type_to_bridge_types(cassandra) ->
|
connector_type_to_bridge_types(cassandra) ->
|
||||||
|
|
Loading…
Reference in New Issue