Merge pull request #10447 from HJianBo/refactor-cassa-dir

refactor: move cassandra bridge into its own app
This commit is contained in:
JianBo He 2023-04-21 20:44:51 +08:00 committed by GitHub
commit 34afa16236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 96 additions and 28 deletions

View File

@ -0,0 +1,2 @@
toxiproxy
cassandra

View File

@ -0,0 +1,5 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%--------------------------------------------------------------------
-define(CASSANDRA_DEFAULT_PORT, 9042).

View File

@ -0,0 +1,11 @@
%% -*- mode: erlang; -*-
{erl_opts, [debug_info]}.
{deps, [ {ecql, {git, "https://github.com/emqx/ecql.git", {tag, "v0.5.1"}}}
, {emqx_connector, {path, "../../apps/emqx_connector"}}
, {emqx_resource, {path, "../../apps/emqx_resource"}}
, {emqx_bridge, {path, "../../apps/emqx_bridge"}}
]}.
{shell, [
{apps, [emqx_bridge_cassandra]}
]}.

View File

@ -2,7 +2,7 @@
{description, "EMQX Enterprise Cassandra Bridge"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib]},
{applications, [kernel, stdlib, ecql]},
{env, []},
{modules, []},
{links, []}

View File

@ -1,7 +1,7 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%--------------------------------------------------------------------
-module(emqx_ee_bridge_cassa).
-module(emqx_bridge_cassandra).
-include_lib("typerefl/include/types.hrl").
-include_lib("hocon/include/hoconsc.hrl").
@ -88,7 +88,7 @@ fields("config") ->
#{desc => ?DESC("local_topic"), default => undefined}
)}
] ++ emqx_resource_schema:fields("resource_opts") ++
(emqx_ee_connector_cassa:fields(config) --
(emqx_bridge_cassandra_connector:fields(config) --
emqx_connector_schema_lib:prepare_statement_fields());
fields("post") ->
fields("post", cassandra);

View File

@ -2,12 +2,12 @@
%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%--------------------------------------------------------------------
-module(emqx_ee_connector_cassa).
-module(emqx_bridge_cassandra_connector).
-behaviour(emqx_resource).
-include_lib("emqx_connector/include/emqx_connector.hrl").
-include_lib("emqx_ee_connector/include/emqx_ee_connector.hrl").
-include("emqx_bridge_cassandra.hrl").
-include_lib("typerefl/include/types.hrl").
-include_lib("emqx/include/logger.hrl").
-include_lib("hocon/include/hoconsc.hrl").

View File

@ -2,7 +2,7 @@
%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%--------------------------------------------------------------------
-module(emqx_ee_bridge_cassa_SUITE).
-module(emqx_bridge_cassandra_SUITE).
-compile(nowarn_export_all).
-compile(export_all).
@ -57,7 +57,7 @@
%% CASSA_TCP_HOST=127.0.0.1 CASSA_TCP_PORT=19042 \
%% CASSA_TLS_HOST=127.0.0.1 CASSA_TLS_PORT=19142 \
%% PROXY_HOST=127.0.0.1 ./rebar3 as test ct -c -v --name ct@127.0.0.1 \
%% --suite lib-ee/emqx_ee_bridge/test/emqx_ee_bridge_cassa_SUITE.erl
%% --suite apps/emqx_bridge_cassandra/test/emqx_bridge_cassandra_SUITE.erl
%%
%%------------------------------------------------------------------------------
@ -590,7 +590,7 @@ t_missing_data(Config) ->
{ok, _},
create_bridge(Config)
),
%% emqx_ee_connector_cassa will send missed data as a `null` atom
%% emqx_bridge_cassandra_connector will send missed data as a `null` atom
%% to ecql driver
?check_trace(
begin

View File

@ -2,13 +2,13 @@
%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%--------------------------------------------------------------------
-module(emqx_ee_connector_cassa_SUITE).
-module(emqx_bridge_cassandra_connector_SUITE).
-compile(nowarn_export_all).
-compile(export_all).
-include("emqx_connector.hrl").
-include("emqx_ee_connector.hrl").
-include("emqx_bridge_cassandra.hrl").
-include("emqx_connector/include/emqx_connector.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("stdlib/include/assert.hrl").
@ -16,7 +16,7 @@
%% Cassandra server defined at `.ci/docker-compose-file/docker-compose-cassandra-tcp.yaml`
%% You can change it to `127.0.0.1`, if you run this SUITE locally
-define(CASSANDRA_HOST, "cassandra").
-define(CASSANDRA_RESOURCE_MOD, emqx_ee_connector_cassa).
-define(CASSANDRA_RESOURCE_MOD, emqx_bridge_cassandra_connector).
%% This test SUITE requires a running cassandra instance. If you don't want to
%% bring up the whole CI infrastuctucture with the `scripts/ct/run.sh` script

View File

@ -10,5 +10,4 @@ tdengine
clickhouse
dynamo
rocketmq
cassandra
sqlserver

View File

@ -1,6 +1,5 @@
{erl_opts, [debug_info]}.
{deps, [ {ecql, {git, "https://github.com/emqx/ecql.git", {tag, "v0.5.1"}}}
, {emqx_connector, {path, "../../apps/emqx_connector"}}
{deps, [ {emqx_connector, {path, "../../apps/emqx_connector"}}
, {emqx_resource, {path, "../../apps/emqx_resource"}}
, {emqx_bridge, {path, "../../apps/emqx_bridge"}}
, {emqx_utils, {path, "../emqx_utils"}}

View File

@ -17,6 +17,7 @@ api_schemas(Method) ->
ref(emqx_bridge_gcp_pubsub, Method),
ref(emqx_bridge_kafka, Method ++ "_consumer"),
ref(emqx_bridge_kafka, Method ++ "_producer"),
ref(emqx_bridge_cassandra, Method),
ref(emqx_ee_bridge_mysql, Method),
ref(emqx_ee_bridge_pgsql, Method),
ref(emqx_ee_bridge_mongodb, Method ++ "_rs"),
@ -34,13 +35,13 @@ api_schemas(Method) ->
ref(emqx_ee_bridge_clickhouse, Method),
ref(emqx_ee_bridge_dynamo, Method),
ref(emqx_ee_bridge_rocketmq, Method),
ref(emqx_ee_bridge_cassa, Method),
ref(emqx_ee_bridge_sqlserver, Method)
].
schema_modules() ->
[
emqx_bridge_kafka,
emqx_bridge_cassandra,
emqx_ee_bridge_hstreamdb,
emqx_bridge_gcp_pubsub,
emqx_ee_bridge_influxdb,
@ -54,7 +55,6 @@ schema_modules() ->
emqx_ee_bridge_clickhouse,
emqx_ee_bridge_dynamo,
emqx_ee_bridge_rocketmq,
emqx_ee_bridge_cassa,
emqx_ee_bridge_sqlserver
].
@ -75,6 +75,7 @@ resource_type(kafka_consumer) -> emqx_bridge_kafka_impl_consumer;
%% TODO: rename this to `kafka_producer' after alias support is added
%% to hocon; keeping this as just `kafka' for backwards compatibility.
resource_type(kafka) -> emqx_bridge_kafka_impl_producer;
resource_type(cassandra) -> emqx_bridge_cassandra_connector;
resource_type(hstreamdb) -> emqx_ee_connector_hstreamdb;
resource_type(gcp_pubsub) -> emqx_bridge_gcp_pubsub_connector;
resource_type(mongodb_rs) -> emqx_ee_connector_mongodb;
@ -93,7 +94,6 @@ resource_type(tdengine) -> emqx_ee_connector_tdengine;
resource_type(clickhouse) -> emqx_ee_connector_clickhouse;
resource_type(dynamo) -> emqx_ee_connector_dynamo;
resource_type(rocketmq) -> emqx_ee_connector_rocketmq;
resource_type(cassandra) -> emqx_ee_connector_cassa;
resource_type(sqlserver) -> emqx_ee_connector_sqlserver.
fields(bridges) ->
@ -148,7 +148,7 @@ fields(bridges) ->
)},
{cassandra,
mk(
hoconsc:map(name, ref(emqx_ee_bridge_cassa, "config")),
hoconsc:map(name, ref(emqx_bridge_cassandra, "config")),
#{
desc => <<"Cassandra Bridge Config">>,
required => false

View File

@ -1,5 +1,4 @@
toxiproxy
influxdb
clickhouse
cassandra
sqlserver

View File

@ -3,4 +3,3 @@
%%-------------------------------------------------------------------
-define(INFLUXDB_DEFAULT_PORT, 8086).
-define(CASSANDRA_DEFAULT_PORT, 9042).

View File

@ -12,7 +12,6 @@
clickhouse,
erlcloud,
rocketmq,
ecql,
odbc
]},
{env, []},

28
mix.exs
View File

@ -155,7 +155,20 @@ defmodule EMQXUmbrella.MixProject do
defp enterprise_umbrella_apps() do
MapSet.new([
:emqx_bridge_kafka,
:emqx_bridge_gcp_pubsub
:emqx_bridge_gcp_pubsub,
:emqx_bridge_cassandra,
:emqx_bridge_clickhouse,
:emqx_bridge_dynamo,
:emqx_bridge_hstreamdb,
:emqx_bridge_influxdb,
:emqx_bridge_matrix,
:emqx_bridge_mongodb,
:emqx_bridge_mysql,
:emqx_bridge_pgsql,
:emqx_bridge_redis,
:emqx_bridge_rocketmq,
:emqx_bridge_tdengine,
:emqx_bridge_timescale
])
end
@ -346,6 +359,19 @@ defmodule EMQXUmbrella.MixProject do
emqx_ee_bridge: :permanent,
emqx_bridge_kafka: :permanent,
emqx_bridge_gcp_pubsub: :permanent,
emqx_bridge_cassandra: :permanent,
emqx_bridge_clickhouse: :permanent,
emqx_bridge_dynamo: :permanent,
emqx_bridge_hstreamdb: :permanent,
emqx_bridge_influxdb: :permanent,
emqx_bridge_matrix: :permanent,
emqx_bridge_mongodb: :permanent,
emqx_bridge_mysql: :permanent,
emqx_bridge_pgsql: :permanent,
emqx_bridge_redis: :permanent,
emqx_bridge_rocketmq: :permanent,
emqx_bridge_tdengine: :permanent,
emqx_bridge_timescale: :permanent,
emqx_ee_schema_registry: :permanent
],
else: []

View File

@ -80,6 +80,19 @@ is_enterprise(ee) -> true.
is_community_umbrella_app("apps/emqx_bridge_kafka") -> false;
is_community_umbrella_app("apps/emqx_bridge_gcp_pubsub") -> false;
is_community_umbrella_app("apps/emqx_bridge_cassandra") -> false;
is_community_umbrella_app("apps/emqx_bridge_clickhouse") -> false;
is_community_umbrella_app("apps/emqx_bridge_dynamo") -> false;
is_community_umbrella_app("apps/emqx_bridge_hstreamdb") -> false;
is_community_umbrella_app("apps/emqx_bridge_influxdb") -> false;
is_community_umbrella_app("apps/emqx_bridge_matrix") -> false;
is_community_umbrella_app("apps/emqx_bridge_mongodb") -> false;
is_community_umbrella_app("apps/emqx_bridge_mysql") -> false;
is_community_umbrella_app("apps/emqx_bridge_pgsql") -> false;
is_community_umbrella_app("apps/emqx_bridge_redis") -> false;
is_community_umbrella_app("apps/emqx_bridge_rocketmq") -> false;
is_community_umbrella_app("apps/emqx_bridge_tdengine") -> false;
is_community_umbrella_app("apps/emqx_bridge_timescale") -> false;
is_community_umbrella_app(_) -> true.
is_jq_supported() ->
@ -441,6 +454,19 @@ relx_apps_per_edition(ee) ->
emqx_ee_bridge,
emqx_bridge_kafka,
emqx_bridge_gcp_pubsub,
emqx_bridge_cassandra,
emqx_bridge_clickhouse,
emqx_bridge_dynamo,
emqx_bridge_hstreamdb,
emqx_bridge_influxdb,
emqx_bridge_matrix,
emqx_bridge_mongodb,
emqx_bridge_mysql,
emqx_bridge_pgsql,
emqx_bridge_redis,
emqx_bridge_rocketmq,
emqx_bridge_tdengine,
emqx_bridge_timescale,
emqx_ee_schema_registry
];
relx_apps_per_edition(ce) ->

View File

@ -1,4 +1,4 @@
emqx_ee_bridge_cassa {
emqx_bridge_cassandra {
config_enable.desc:
"""Enable or disable this bridge"""

View File

@ -1,4 +1,4 @@
emqx_ee_connector_cassa {
emqx_bridge_cassandra_connector {
keyspace.desc:
"""Keyspace name to connect to."""

View File

@ -108,9 +108,12 @@ case "${WHICH_APP}" in
## ensure enterprise profile when testing lib-ee applications
export PROFILE='emqx-enterprise'
;;
apps/emqx_bridge_kafka)
## ensure enterprise profile when testing ee applications
export PROFILE='emqx-enterprise'
apps/*)
if [[ -f "${WHICH_APP}/BSL.txt" ]]; then
export PROFILE='emqx-enterprise'
else
export PROFILE='emqx'
fi
;;
*)
export PROFILE="${PROFILE:-emqx}"