fix(sysk): improve the seakeeper schema

This commit is contained in:
firest 2024-01-08 15:25:56 +08:00
parent 7f57ec47d5
commit 2fb1569363
7 changed files with 9 additions and 12 deletions

View File

@ -61,7 +61,6 @@ values(put) ->
connector => <<"syskeeper_forwarder">>, connector => <<"syskeeper_forwarder">>,
parameters => #{ parameters => #{
target_topic => <<"${topic}">>, target_topic => <<"${topic}">>,
target_qos => <<"-1">>,
template => <<"${payload}">> template => <<"${payload}">>
}, },
resource_opts => #{ resource_opts => #{
@ -117,8 +116,8 @@ fields("parameters") ->
)}, )},
{target_qos, {target_qos,
mk( mk(
range(-1, 2), range(1, 2),
#{desc => ?DESC("target_qos"), default => -1} #{desc => ?DESC("target_qos"), required => false}
)}, )},
{template, {template,
mk( mk(

View File

@ -219,9 +219,8 @@ on_add_channel(
#{ #{
parameters := #{ parameters := #{
target_topic := TargetTopic, target_topic := TargetTopic,
target_qos := TargetQoS,
template := Template template := Template
} } = Parameters
} }
) -> ) ->
case maps:is_key(ChannelId, Channels) of case maps:is_key(ChannelId, Channels) of
@ -229,7 +228,7 @@ on_add_channel(
{error, already_exists}; {error, already_exists};
_ -> _ ->
Channel = #{ Channel = #{
target_qos => TargetQoS, target_qos => maps:get(target_qos, Parameters, undefined),
target_topic => emqx_placeholder:preproc_tmpl(TargetTopic), target_topic => emqx_placeholder:preproc_tmpl(TargetTopic),
template => emqx_placeholder:preproc_tmpl(Template) template => emqx_placeholder:preproc_tmpl(Template)
}, },
@ -335,7 +334,7 @@ render_message(#{id := Id, qos := QoS, clientid := From} = Data, #{
id => emqx_guid:from_hexstr(Id), id => emqx_guid:from_hexstr(Id),
qos := qos :=
case TargetQoS of case TargetQoS of
-1 -> undefined ->
QoS; QoS;
_ -> _ ->
TargetQoS TargetQoS

View File

@ -1,5 +1,5 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Copyright (c) 2022 EMQ Technologies Co., Ltd. All Rights Reserved. %% Copyright (c) 2022-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
%% %%
%% @doc EMQ X Bridge Sysk Frame %% @doc EMQ X Bridge Sysk Frame
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Copyright (c) 2022 EMQ Technologies Co., Ltd. All Rights Reserved. %% Copyright (c) 2022-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
%% %%
%% @doc EMQ X Bridge Sysk Frame version 1 %% @doc EMQ X Bridge Sysk Frame version 1
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Copyright (c) 2022 EMQ Technologies Co., Ltd. All Rights Reserved. %% Copyright (c) 2022-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-module(emqx_bridge_syskeeper_proxy). -module(emqx_bridge_syskeeper_proxy).

View File

@ -110,7 +110,6 @@ syskeeper_config(Config) ->
" connector = ~ts\n" " connector = ~ts\n"
" parameters = {\n" " parameters = {\n"
" target_topic = \"${topic}\"\n" " target_topic = \"${topic}\"\n"
" target_qos = -1\n"
" template = \"${payload}\"\n" " template = \"${payload}\"\n"
" },\n" " },\n"
" resource_opts = {\n" " resource_opts = {\n"

View File

@ -37,7 +37,7 @@ target_topic.label:
"""Target Topic""" """Target Topic"""
target_qos.desc: target_qos.desc:
"""The QoS for the forwarded message, -1 is for the original topic""" """The QoS for the forwarded message, to reuse the original qos this value can be omitted"""
target_qos.label: target_qos.label:
"""Target QoS""" """Target QoS"""