fix: azure event hub names are defined in one place

This commit is contained in:
Kjell Winblad 2023-11-10 07:07:09 +01:00 committed by Ivan Dyachkov
parent 5e8e407017
commit 49fdfef8c3
3 changed files with 35 additions and 36 deletions

View File

@ -41,7 +41,10 @@
-if(?EMQX_RELEASE_EDITION == ee).
hard_coded_action_info_modules_ee() ->
[emqx_bridge_kafka_action_info].
[
emqx_bridge_kafka_action_info,
emqx_bridge_azure_event_hub_action_info
].
-else.
hard_coded_action_info_modules_ee() ->
[].
@ -63,52 +66,30 @@ action_type_to_connector_type(Type) ->
ActionInfoMap = info_map(),
ActionTypeToConnectorTypeMap = maps:get(action_type_to_connector_type, ActionInfoMap),
case maps:get(Type, ActionTypeToConnectorTypeMap, undefined) of
undefined -> action_type_to_connector_type_old(Type);
undefined -> Type;
ConnectorType -> ConnectorType
end.
% action_type_to_connector_type_old(kafka) ->
% %% backward compatible
% kafka_producer;
% action_type_to_connector_type_old(kafka_producer) ->
% kafka_producer;
action_type_to_connector_type_old(azure_event_hub_producer) ->
azure_event_hub_producer.
bridge_v1_type_to_action_type(Bin) when is_binary(Bin) ->
bridge_v1_type_to_action_type(binary_to_existing_atom(Bin));
bridge_v1_type_to_action_type(Type) ->
ActionInfoMap = info_map(),
BridgeV1TypeToActionType = maps:get(bridge_v1_type_to_action_type, ActionInfoMap),
case maps:get(Type, BridgeV1TypeToActionType, undefined) of
undefined -> bridge_v1_type_to_action_type_old(Type);
undefined -> Type;
ActionType -> ActionType
end.
% bridge_v1_type_to_action_type_old(kafka) ->
% kafka_producer;
% bridge_v1_type_to_action_type_old(kafka_producer) ->
% kafka_producer;
bridge_v1_type_to_action_type_old(azure_event_hub_producer) ->
azure_event_hub_producer;
bridge_v1_type_to_action_type_old(Type) ->
Type.
action_type_to_bridge_v1_type(Bin) when is_binary(Bin) ->
action_type_to_bridge_v1_type(binary_to_existing_atom(Bin));
action_type_to_bridge_v1_type(Type) ->
ActionInfoMap = info_map(),
ActionTypeToBridgeV1Type = maps:get(action_type_to_bridge_v1_type, ActionInfoMap),
case maps:get(Type, ActionTypeToBridgeV1Type, undefined) of
undefined -> action_type_to_bridge_v1_type_old(Type);
undefined -> Type;
BridgeV1Type -> BridgeV1Type
end.
action_type_to_bridge_v1_type_old(azure_event_hub_producer) ->
azure_event_hub_producer;
action_type_to_bridge_v1_type_old(Type) ->
Type.
%% This function should return true for all inputs that are bridge V1 types for
%% bridges that have been refactored to bridge V2s, and for all all bridge V2
%% types. For everything else the function should return false.
@ -118,19 +99,10 @@ is_action_type(Type) ->
ActionInfoMap = info_map(),
ActionTypes = maps:get(action_type_names, ActionInfoMap),
case maps:get(Type, ActionTypes, undefined) of
undefined -> is_action_type_old(Type);
undefined -> false;
_ -> true
end.
% is_action_type_old(kafka_producer) ->
% true;
% is_action_type_old(kafka) ->
% true;
is_action_type_old(azure_event_hub_producer) ->
true;
is_action_type_old(_) ->
false.
registered_schema_modules() ->
InfoMap = info_map(),
Schemas = maps:get(action_type_to_schema_module, InfoMap),

View File

@ -114,6 +114,15 @@ fields(kafka_message) ->
Fields0 = emqx_bridge_kafka:fields(kafka_message),
Fields = proplists:delete(timestamp, Fields0),
override_documentations(Fields);
fields(action) ->
{azure_event_hub_producer,
mk(
hoconsc:map(name, ref(emqx_bridge_azure_event_hub, actions)),
#{
desc => <<"Azure Event Hub Actions Config">>,
required => false
}
)};
fields(actions) ->
Fields =
override(

View File

@ -0,0 +1,18 @@
-module(emqx_bridge_azure_event_hub_action_info).
-behaviour(emqx_action_info).
-export([
bridge_v1_type_name/0,
action_type_name/0,
connector_type_name/0,
schema_module/0
]).
bridge_v1_type_name() -> azure_event_hub_producer.
action_type_name() -> azure_event_hub_producer.
connector_type_name() -> azure_event_hub_producer.
schema_module() -> emqx_bridge_azure_event_hub.