fix: azure event hub names are defined in one place
This commit is contained in:
parent
5e8e407017
commit
49fdfef8c3
|
@ -41,7 +41,10 @@
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
-if(?EMQX_RELEASE_EDITION == ee).
|
||||||
hard_coded_action_info_modules_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.
|
-else.
|
||||||
hard_coded_action_info_modules_ee() ->
|
hard_coded_action_info_modules_ee() ->
|
||||||
[].
|
[].
|
||||||
|
@ -63,52 +66,30 @@ action_type_to_connector_type(Type) ->
|
||||||
ActionInfoMap = info_map(),
|
ActionInfoMap = info_map(),
|
||||||
ActionTypeToConnectorTypeMap = maps:get(action_type_to_connector_type, ActionInfoMap),
|
ActionTypeToConnectorTypeMap = maps:get(action_type_to_connector_type, ActionInfoMap),
|
||||||
case maps:get(Type, ActionTypeToConnectorTypeMap, undefined) of
|
case maps:get(Type, ActionTypeToConnectorTypeMap, undefined) of
|
||||||
undefined -> action_type_to_connector_type_old(Type);
|
undefined -> Type;
|
||||||
ConnectorType -> ConnectorType
|
ConnectorType -> ConnectorType
|
||||||
end.
|
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(Bin) when is_binary(Bin) ->
|
||||||
bridge_v1_type_to_action_type(binary_to_existing_atom(Bin));
|
bridge_v1_type_to_action_type(binary_to_existing_atom(Bin));
|
||||||
bridge_v1_type_to_action_type(Type) ->
|
bridge_v1_type_to_action_type(Type) ->
|
||||||
ActionInfoMap = info_map(),
|
ActionInfoMap = info_map(),
|
||||||
BridgeV1TypeToActionType = maps:get(bridge_v1_type_to_action_type, ActionInfoMap),
|
BridgeV1TypeToActionType = maps:get(bridge_v1_type_to_action_type, ActionInfoMap),
|
||||||
case maps:get(Type, BridgeV1TypeToActionType, undefined) of
|
case maps:get(Type, BridgeV1TypeToActionType, undefined) of
|
||||||
undefined -> bridge_v1_type_to_action_type_old(Type);
|
undefined -> Type;
|
||||||
ActionType -> ActionType
|
ActionType -> ActionType
|
||||||
end.
|
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(Bin) when is_binary(Bin) ->
|
||||||
action_type_to_bridge_v1_type(binary_to_existing_atom(Bin));
|
action_type_to_bridge_v1_type(binary_to_existing_atom(Bin));
|
||||||
action_type_to_bridge_v1_type(Type) ->
|
action_type_to_bridge_v1_type(Type) ->
|
||||||
ActionInfoMap = info_map(),
|
ActionInfoMap = info_map(),
|
||||||
ActionTypeToBridgeV1Type = maps:get(action_type_to_bridge_v1_type, ActionInfoMap),
|
ActionTypeToBridgeV1Type = maps:get(action_type_to_bridge_v1_type, ActionInfoMap),
|
||||||
case maps:get(Type, ActionTypeToBridgeV1Type, undefined) of
|
case maps:get(Type, ActionTypeToBridgeV1Type, undefined) of
|
||||||
undefined -> action_type_to_bridge_v1_type_old(Type);
|
undefined -> Type;
|
||||||
BridgeV1Type -> BridgeV1Type
|
BridgeV1Type -> BridgeV1Type
|
||||||
end.
|
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
|
%% 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
|
%% bridges that have been refactored to bridge V2s, and for all all bridge V2
|
||||||
%% types. For everything else the function should return false.
|
%% types. For everything else the function should return false.
|
||||||
|
@ -118,19 +99,10 @@ is_action_type(Type) ->
|
||||||
ActionInfoMap = info_map(),
|
ActionInfoMap = info_map(),
|
||||||
ActionTypes = maps:get(action_type_names, ActionInfoMap),
|
ActionTypes = maps:get(action_type_names, ActionInfoMap),
|
||||||
case maps:get(Type, ActionTypes, undefined) of
|
case maps:get(Type, ActionTypes, undefined) of
|
||||||
undefined -> is_action_type_old(Type);
|
undefined -> false;
|
||||||
_ -> true
|
_ -> true
|
||||||
end.
|
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() ->
|
registered_schema_modules() ->
|
||||||
InfoMap = info_map(),
|
InfoMap = info_map(),
|
||||||
Schemas = maps:get(action_type_to_schema_module, InfoMap),
|
Schemas = maps:get(action_type_to_schema_module, InfoMap),
|
||||||
|
|
|
@ -114,6 +114,15 @@ fields(kafka_message) ->
|
||||||
Fields0 = emqx_bridge_kafka:fields(kafka_message),
|
Fields0 = emqx_bridge_kafka:fields(kafka_message),
|
||||||
Fields = proplists:delete(timestamp, Fields0),
|
Fields = proplists:delete(timestamp, Fields0),
|
||||||
override_documentations(Fields);
|
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(actions) ->
|
||||||
Fields =
|
Fields =
|
||||||
override(
|
override(
|
||||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue