chore(schema): use emqx_schema:qos() instead of union integer.

This commit is contained in:
zhongwencool 2022-02-11 10:08:51 +08:00
parent 97e22cc6a8
commit f5415589e9
6 changed files with 11 additions and 14 deletions

View File

@ -35,12 +35,10 @@ fields("auto_subscribe") ->
fields("topic") ->
[ {topic, sc(binary(), #{example => topic_example()})}
, {qos, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]),
#{default => 0})}
, {rh, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]),
#{default => 0})}
, {rap, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1)]), #{default => 0})}
, {nl, sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1)]), #{default => 0})}
, {qos, sc(emqx_schema:qos(), #{default => 0})}
, {rh, sc(range(0,2), #{default => 0})}
, {rap, sc(range(0, 1), #{default => 0})}
, {nl, sc(range(0, 1), #{default => 0})}
].
topic_example() ->

View File

@ -236,7 +236,7 @@ Template with variables is allowed."""
].
qos() ->
hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2), binary()]).
hoconsc:union([emqx_schema:qos(), binary()]).
sc(Type, Meta) -> hoconsc:mk(Type, Meta).
ref(Field) -> hoconsc:ref(?MODULE, Field).

View File

@ -189,7 +189,7 @@ The type of delivered coap message can be set to:<br>
3. qos: Mapping from QoS type of received message, QoS0 -> non, QoS1,2 -> con"
})}
, {subscribe_qos,
sc(hoconsc:union([qos0, qos1, qos2, coap]),
sc(hoconsc:enum([qos0, qos1, qos2, coap]),
#{ default => coap
, desc =>
"The Default QoS Level indicator for subscribe request.<br>
@ -202,7 +202,7 @@ The indicator can be set to:
* qos1: If the subscribe request is confirmable"
})}
, {publish_qos,
sc(hoconsc:union([qos0, qos1, qos2, coap]),
sc(hoconsc:enum([qos0, qos1, qos2, coap]),
#{ default => coap
, desc =>
"The Default QoS Level indicator for publish request.<br>
@ -356,7 +356,7 @@ notifyevents via this topic, if the client reports any resource changes"
fields(translator) ->
[ {topic, sc(binary(), #{nullable => false})}
, {qos, sc(range(0, 2), #{default => 0})}
, {qos, sc(emqx_schema:qos(), #{default => 0})}
];
fields(udp_listeners) ->

View File

@ -207,8 +207,7 @@ fields("ctx_disconnected") ->
].
qos() ->
{"qos", sc(hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]),
#{desc => "The Message QoS"})}.
{"qos", sc(emqx_schema:qos(), #{desc => "The Message QoS"})}.
rule_id() ->
{"id", sc(binary(),

View File

@ -194,7 +194,7 @@ outputs() ->
].
qos() ->
hoconsc:union([typerefl:integer(0), typerefl:integer(1), typerefl:integer(2), binary()]).
hoconsc:union([emqx_schema:qos(), binary()]).
validate_sql(Sql) ->
case emqx_rule_sqlparser:parse(Sql) of

View File

@ -30,7 +30,7 @@ fields("slow_subs") ->
"publish is disabled if set to 0s."
)}
, {notice_qos,
sc(range(0, 2),
sc(emqx_schema:qos(),
0,
"QoS of notification message in notice topic")}
, {notice_batch_size,