fix: subscription about api, mqtt5 options param (#5620)
This commit is contained in:
parent
c4e279bb76
commit
c7bc2e1a8d
|
@ -4,10 +4,12 @@ auto_subscribe {
|
||||||
# {
|
# {
|
||||||
# topic = "/c/${clientid}",
|
# topic = "/c/${clientid}",
|
||||||
# qos = 0
|
# qos = 0
|
||||||
# },
|
# rh = 0
|
||||||
|
# rap = 0
|
||||||
|
# nl = 0
|
||||||
|
# }
|
||||||
# {
|
# {
|
||||||
# topic = "/u/${username}",
|
# topic = "/u/${username}",
|
||||||
# qos = 1
|
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# topic = "/h/${host}",
|
# topic = "/h/${host}",
|
||||||
|
@ -15,15 +17,12 @@ auto_subscribe {
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# topic = "/p/${port}",
|
# topic = "/p/${port}",
|
||||||
# qos = 0
|
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# topic = "/topic/abc",
|
# topic = "/topic/abc",
|
||||||
# qos = 0
|
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# topic = "/client/${clientid}/username/${username}/host/${host}/port/${port}",
|
# topic = "/client/${clientid}/username/${username}/host/${host}/port/${port}",
|
||||||
# qos = 0
|
|
||||||
# }
|
# }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ api_spec() ->
|
||||||
schema() ->
|
schema() ->
|
||||||
emqx_mgmt_util:schema(
|
emqx_mgmt_util:schema(
|
||||||
emqx_mgmt_api_configs:gen_schema(
|
emqx_mgmt_api_configs:gen_schema(
|
||||||
emqx:get_raw_config([auto_subscribe, topics]))).
|
emqx:get_raw_config([auto_subscribe, topics])), <<"">>).
|
||||||
|
|
||||||
auto_subscribe_api() ->
|
auto_subscribe_api() ->
|
||||||
Metadata = #{
|
Metadata = #{
|
||||||
|
|
|
@ -23,16 +23,17 @@
|
||||||
generate(Topics) when is_list(Topics) ->
|
generate(Topics) when is_list(Topics) ->
|
||||||
[generate(Topic) || Topic <- Topics];
|
[generate(Topic) || Topic <- Topics];
|
||||||
|
|
||||||
generate(#{qos := Qos, topic := Topic}) when is_binary(Topic) ->
|
generate(T0 = #{topic := Topic}) ->
|
||||||
#{qos => Qos, placeholder => generate(Topic, [])}.
|
T = maps:without([topic], T0),
|
||||||
|
T#{placeholder => generate(Topic, [])}.
|
||||||
|
|
||||||
-spec(to_topic_table(list(), map(), map()) -> list()).
|
-spec(to_topic_table(list(), map(), map()) -> list()).
|
||||||
to_topic_table(PlaceHolders, ClientInfo, ConnInfo) ->
|
to_topic_table(PHs, ClientInfo, ConnInfo) ->
|
||||||
[begin
|
[begin
|
||||||
Topic0 = to_topic(PlaceHolder, ClientInfo, ConnInfo, []),
|
Topic0 = to_topic(PlaceHolder, ClientInfo, ConnInfo, []),
|
||||||
{Topic, Opts} = emqx_topic:parse(Topic0),
|
{Topic, Opts} = emqx_topic:parse(Topic0),
|
||||||
{Topic, Opts#{qos => Qos}}
|
{Topic, Opts#{qos => Qos, rh => RH, rap => RAP, nl => NL}}
|
||||||
end || #{qos := Qos, placeholder := PlaceHolder} <- PlaceHolders].
|
end || #{qos := Qos, rh := RH, rap := RAP, nl := NL, placeholder := PlaceHolder} <- PHs].
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% internal
|
%% internal
|
||||||
|
|
|
@ -30,5 +30,14 @@ fields("auto_subscribe") ->
|
||||||
|
|
||||||
fields("topic") ->
|
fields("topic") ->
|
||||||
[ {topic, emqx_schema:t(binary())}
|
[ {topic, emqx_schema:t(binary())}
|
||||||
, {qos, emqx_schema:t(integer(), undefined, 0)}
|
, {qos, t(hoconsc:union([0, 1, 2]), 0)}
|
||||||
|
, {rh, t(hoconsc:union([0, 1, 2]), 0)}
|
||||||
|
, {rap, t(hoconsc:union([0, 1]), 0)}
|
||||||
|
, {nl, t(hoconsc:union([0, 1]), 0)}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Internal functions
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
t(Type, Default) ->
|
||||||
|
hoconsc:t(Type, #{default => Default}).
|
||||||
|
|
Loading…
Reference in New Issue