chore: add desc for rabbitmq source
This commit is contained in:
parent
b444c82a42
commit
688701eedb
|
@ -78,7 +78,7 @@ fields("config") ->
|
||||||
{local_topic,
|
{local_topic,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
binary(),
|
||||||
#{desc => ?DESC("local_topic"), default => undefined}
|
#{desc => ?DESC("local_topic")}
|
||||||
)},
|
)},
|
||||||
{resource_opts,
|
{resource_opts,
|
||||||
mk(
|
mk(
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-module(emqx_bridge_rabbitmq_connector).
|
-module(emqx_bridge_rabbitmq_connector).
|
||||||
%-feature(maybe_expr, enable).
|
|
||||||
|
-feature(maybe_expr, enable).
|
||||||
-include_lib("emqx_connector/include/emqx_connector.hrl").
|
-include_lib("emqx_connector/include/emqx_connector.hrl").
|
||||||
-include_lib("emqx_resource/include/emqx_resource.hrl").
|
-include_lib("emqx_resource/include/emqx_resource.hrl").
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
|
|
@ -106,6 +106,8 @@ fields("get") ->
|
||||||
|
|
||||||
desc("config_connector") ->
|
desc("config_connector") ->
|
||||||
?DESC("config_connector");
|
?DESC("config_connector");
|
||||||
|
desc(connector_resource_opts) ->
|
||||||
|
?DESC(connector_resource_opts);
|
||||||
desc(_) ->
|
desc(_) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
-define(ACTION_TYPE, rabbitmq).
|
-define(ACTION_TYPE, rabbitmq).
|
||||||
-define(SOURCE_TYPE, rabbitmq).
|
-define(SOURCE_TYPE, rabbitmq).
|
||||||
|
-define(CONNECTOR_SCHEMA, emqx_bridge_rabbitmq_connector_schema).
|
||||||
|
|
||||||
%%======================================================================================
|
%%======================================================================================
|
||||||
%% Hocon Schema Definitions
|
%% Hocon Schema Definitions
|
||||||
|
@ -61,7 +62,7 @@ fields(action_parameters) ->
|
||||||
boolean(),
|
boolean(),
|
||||||
#{
|
#{
|
||||||
default => true,
|
default => true,
|
||||||
desc => ?DESC("wait_for_publish_confirmations")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "wait_for_publish_confirmations")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{publish_confirmation_timeout,
|
{publish_confirmation_timeout,
|
||||||
|
@ -69,7 +70,7 @@ fields(action_parameters) ->
|
||||||
emqx_schema:timeout_duration_ms(),
|
emqx_schema:timeout_duration_ms(),
|
||||||
#{
|
#{
|
||||||
default => <<"30s">>,
|
default => <<"30s">>,
|
||||||
desc => ?DESC("timeout")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "timeout")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{exchange,
|
{exchange,
|
||||||
|
@ -77,7 +78,7 @@ fields(action_parameters) ->
|
||||||
typerefl:binary(),
|
typerefl:binary(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("exchange")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "exchange")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{routing_key,
|
{routing_key,
|
||||||
|
@ -85,7 +86,7 @@ fields(action_parameters) ->
|
||||||
typerefl:binary(),
|
typerefl:binary(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("routing_key")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "routing_key")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{delivery_mode,
|
{delivery_mode,
|
||||||
|
@ -93,15 +94,14 @@ fields(action_parameters) ->
|
||||||
hoconsc:enum([non_persistent, persistent]),
|
hoconsc:enum([non_persistent, persistent]),
|
||||||
#{
|
#{
|
||||||
default => non_persistent,
|
default => non_persistent,
|
||||||
desc => ?DESC("delivery_mode")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "delivery_mode")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{payload_template,
|
{payload_template,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
binary(),
|
binary(),
|
||||||
#{
|
#{
|
||||||
default => <<"${.}">>,
|
desc => ?DESC(?CONNECTOR_SCHEMA, "payload_template")
|
||||||
desc => ?DESC("payload_template")
|
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
@ -117,21 +117,21 @@ fields(source) ->
|
||||||
fields(subscriber_source) ->
|
fields(subscriber_source) ->
|
||||||
emqx_bridge_v2_schema:make_consumer_action_schema(
|
emqx_bridge_v2_schema:make_consumer_action_schema(
|
||||||
?HOCON(
|
?HOCON(
|
||||||
?R_REF(ingress_parameters),
|
?R_REF(source_parameters),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("source_parameters")
|
desc => ?DESC("source_parameters")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
fields(ingress_parameters) ->
|
fields(source_parameters) ->
|
||||||
[
|
[
|
||||||
{wait_for_publish_confirmations,
|
{wait_for_publish_confirmations,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
boolean(),
|
boolean(),
|
||||||
#{
|
#{
|
||||||
default => true,
|
default => true,
|
||||||
desc => ?DESC("wait_for_publish_confirmations")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "wait_for_publish_confirmations")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{topic,
|
{topic,
|
||||||
|
@ -140,7 +140,7 @@ fields(ingress_parameters) ->
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
validator => fun emqx_schema:non_empty_string/1,
|
validator => fun emqx_schema:non_empty_string/1,
|
||||||
desc => ?DESC("ingress_topic")
|
desc => ?DESC("source_topic")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{qos,
|
{qos,
|
||||||
|
@ -148,7 +148,7 @@ fields(ingress_parameters) ->
|
||||||
?UNION([emqx_schema:qos(), binary()]),
|
?UNION([emqx_schema:qos(), binary()]),
|
||||||
#{
|
#{
|
||||||
default => 0,
|
default => 0,
|
||||||
desc => ?DESC("ingress_qos")
|
desc => ?DESC("source_qos")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{payload_template,
|
{payload_template,
|
||||||
|
@ -156,7 +156,7 @@ fields(ingress_parameters) ->
|
||||||
binary(),
|
binary(),
|
||||||
#{
|
#{
|
||||||
required => false,
|
required => false,
|
||||||
desc => ?DESC("ingress_payload_template")
|
desc => ?DESC("source_payload_template")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{queue,
|
{queue,
|
||||||
|
@ -164,7 +164,7 @@ fields(ingress_parameters) ->
|
||||||
binary(),
|
binary(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("ingress_queue")
|
desc => ?DESC("source_queue")
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{no_ack,
|
{no_ack,
|
||||||
|
@ -173,7 +173,7 @@ fields(ingress_parameters) ->
|
||||||
#{
|
#{
|
||||||
required => false,
|
required => false,
|
||||||
default => true,
|
default => true,
|
||||||
desc => ?DESC("ingress_no_ack")
|
desc => ?DESC("source_no_ack")
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
@ -210,8 +210,8 @@ desc(source_resource_opts) ->
|
||||||
?DESC(emqx_resource_schema, "creation_opts");
|
?DESC(emqx_resource_schema, "creation_opts");
|
||||||
desc(action_parameters) ->
|
desc(action_parameters) ->
|
||||||
?DESC(action_parameters);
|
?DESC(action_parameters);
|
||||||
desc(ingress_parameters) ->
|
desc(source_parameters) ->
|
||||||
?DESC(ingress_parameters);
|
?DESC(source_parameters);
|
||||||
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
||||||
["Configuration for WebHook using `", string:to_upper(Method), "` method."];
|
["Configuration for WebHook using `", string:to_upper(Method), "` method."];
|
||||||
desc("http_action") ->
|
desc("http_action") ->
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-module(emqx_bridge_rabbitmq_sup).
|
-module(emqx_bridge_rabbitmq_sup).
|
||||||
|
|
||||||
|
-feature(maybe_expr, enable).
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
|
|
||||||
-export([ensure_started/2]).
|
-export([ensure_started/2]).
|
||||||
|
|
|
@ -731,17 +731,17 @@ schema_homogeneous_test() ->
|
||||||
is_bad_schema(#{type := ?MAP(_, ?R_REF(Module, TypeName))}) ->
|
is_bad_schema(#{type := ?MAP(_, ?R_REF(Module, TypeName))}) ->
|
||||||
Fields = Module:fields(TypeName),
|
Fields = Module:fields(TypeName),
|
||||||
ExpectedFieldNames = common_field_names(),
|
ExpectedFieldNames = common_field_names(),
|
||||||
MissingFileds = lists:filter(
|
MissingFields = lists:filter(
|
||||||
fun(Name) -> lists:keyfind(Name, 1, Fields) =:= false end, ExpectedFieldNames
|
fun(Name) -> lists:keyfind(Name, 1, Fields) =:= false end, ExpectedFieldNames
|
||||||
),
|
),
|
||||||
case MissingFileds of
|
case MissingFields of
|
||||||
[] ->
|
[] ->
|
||||||
false;
|
false;
|
||||||
_ ->
|
_ ->
|
||||||
{true, #{
|
{true, #{
|
||||||
schema_module => Module,
|
schema_module => Module,
|
||||||
type_name => TypeName,
|
type_name => TypeName,
|
||||||
missing_fields => MissingFileds
|
missing_fields => MissingFields
|
||||||
}}
|
}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
warn_unused_import,
|
warn_unused_import,
|
||||||
warn_obsolete_guard,
|
warn_obsolete_guard,
|
||||||
compressed,
|
compressed,
|
||||||
{feature, maybe_expr, enable},
|
|
||||||
nowarn_unused_import,
|
nowarn_unused_import,
|
||||||
{d, snk_kind, msg}
|
{d, snk_kind, msg}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
emqx_bridge_rabbitmq_connector {
|
emqx_bridge_rabbitmq_connector_schema {
|
||||||
|
|
||||||
server.desc:
|
server.desc:
|
||||||
"""The RabbitMQ server address that you want to connect to (for example, localhost)."""
|
"""The RabbitMQ server address that you want to connect to (for example, localhost)."""
|
||||||
|
@ -97,4 +97,15 @@ wait_for_publish_confirmations.desc:
|
||||||
wait_for_publish_confirmations.label:
|
wait_for_publish_confirmations.label:
|
||||||
"""Wait for Publish Confirmations"""
|
"""Wait for Publish Confirmations"""
|
||||||
|
|
||||||
|
connector_resource_opts.desc:
|
||||||
|
"""Connector resource options."""
|
||||||
|
|
||||||
|
connector_resource_opts.label:
|
||||||
|
"""Connector Resource Options"""
|
||||||
|
|
||||||
|
config_connector.desc:
|
||||||
|
"""The configuration for the RabbitMQ connector."""
|
||||||
|
config_connector.label:
|
||||||
|
"""RabbitMQ Connector Configuration"""
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
emqx_bridge_rabbitmq_pubsub_schema {
|
||||||
|
|
||||||
|
publisher_action.desc:
|
||||||
|
"""Action configs."""
|
||||||
|
publisher_action.label:
|
||||||
|
"""Action"""
|
||||||
|
|
||||||
|
subscriber_source.desc:
|
||||||
|
"""Source configs."""
|
||||||
|
subscriber_source.label:
|
||||||
|
"""Source"""
|
||||||
|
|
||||||
|
|
||||||
|
action_parameters.desc:
|
||||||
|
"""The action config defines how this bridge send messages to the remote RabbitMQ broker"""
|
||||||
|
action_parameters.label:
|
||||||
|
"""Action Parameters"""
|
||||||
|
|
||||||
|
source_parameters.desc:
|
||||||
|
"""The source config defines how this bridge receive messages from the remote RabbitMQ broker"""
|
||||||
|
source_parameters.label:
|
||||||
|
"""Source Parameters"""
|
||||||
|
|
||||||
|
source_topic.desc:
|
||||||
|
"""Topic used for constructing MQTT messages, supporting templates."""
|
||||||
|
source_topic.label:
|
||||||
|
"""Source Topic"""
|
||||||
|
|
||||||
|
source_qos.desc:
|
||||||
|
"""The QoS level of the MQTT message, supporting templates."""
|
||||||
|
source_qos.label:
|
||||||
|
"""QoS"""
|
||||||
|
|
||||||
|
source_payload_template.desc:
|
||||||
|
"""The template used to construct the payload of the MQTT message."""
|
||||||
|
source_payload_template.label:
|
||||||
|
"""Source Payload Template"""
|
||||||
|
|
||||||
|
source_queue.desc:
|
||||||
|
"""The queue name of the RabbitMQ broker."""
|
||||||
|
source_queue.label:
|
||||||
|
"""Source Queue"""
|
||||||
|
|
||||||
|
source_no_ack.desc:
|
||||||
|
"""Whether to use no_ack mode when consuming messages from the RabbitMQ broker."""
|
||||||
|
source_no_ack.label:
|
||||||
|
"""Source No Ack"""
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue