fix: page & limit & pool_size pos_integer; some bad spelling

This commit is contained in:
DDDHuang 2022-04-14 17:07:52 +08:00
parent 20b34364d9
commit e22d01d25f
14 changed files with 59 additions and 82 deletions

View File

@ -149,8 +149,8 @@ fields(response_users) ->
paginated_list_type(ref(response_user)); paginated_list_type(ref(response_user));
fields(pagination_meta) -> fields(pagination_meta) ->
[ [
{page, non_neg_integer()}, {page, pos_integer()},
{limit, non_neg_integer()}, {limit, pos_integer()},
{count, non_neg_integer()} {count, non_neg_integer()}
]. ].
@ -431,8 +431,8 @@ schema("/authentication/:id/users") ->
description => <<"List users in authenticator in global authentication chain">>, description => <<"List users in authenticator in global authentication chain">>,
parameters => [ parameters => [
param_auth_id(), param_auth_id(),
{page, mk(integer(), #{in => query, desc => <<"Page Index">>, required => false})}, {page, mk(pos_integer(), #{in => query, desc => <<"Page Index">>, required => false})},
{limit, mk(integer(), #{in => query, desc => <<"Page Limit">>, required => false})}, {limit, mk(pos_integer(), #{in => query, desc => <<"Page Limit">>, required => false})},
{like_username, {like_username,
mk(binary(), #{ mk(binary(), #{
in => query, in => query,
@ -481,8 +481,8 @@ schema("/listeners/:listener_id/authentication/:id/users") ->
parameters => [ parameters => [
param_listener_id(), param_listener_id(),
param_auth_id(), param_auth_id(),
{page, mk(integer(), #{in => query, desc => <<"Page Index">>, required => false})}, {page, mk(pos_integer(), #{in => query, desc => <<"Page Index">>, required => false})},
{limit, mk(integer(), #{in => query, desc => <<"Page Limit">>, required => false})} {limit, mk(pos_integer(), #{in => query, desc => <<"Page Limit">>, required => false})}
], ],
responses => #{ responses => #{
200 => emqx_dashboard_swagger:schema_with_example( 200 => emqx_dashboard_swagger:schema_with_example(

View File

@ -95,7 +95,7 @@ For example: `http://localhost:9901/`
, desc => "The type of the pool. Can be one of `random`, `hash`." , desc => "The type of the pool. Can be one of `random`, `hash`."
})} })}
, {pool_size, , {pool_size,
sc(non_neg_integer(), sc(pos_integer(),
#{ default => 8 #{ default => 8
, desc => "The pool size." , desc => "The pool size."
})} })}

View File

@ -76,7 +76,9 @@ fields(sharded) ->
, {w_mode, fun w_mode/1} , {w_mode, fun w_mode/1}
] ++ mongo_fields(); ] ++ mongo_fields();
fields(topology) -> fields(topology) ->
[ {pool_size, fun internal_pool_size/1} [ {pool_size, fun emqx_connector_schema_lib:pool_size/1}
%% TODO: what is this
%% 'max_overflow'
, {max_overflow, fun emqx_connector_schema_lib:pool_size/1} , {max_overflow, fun emqx_connector_schema_lib:pool_size/1}
, {overflow_ttl, fun duration/1} , {overflow_ttl, fun duration/1}
, {overflow_check_period, fun duration/1} , {overflow_check_period, fun duration/1}
@ -114,12 +116,6 @@ mongo_fields() ->
] ++ ] ++
emqx_connector_schema_lib:ssl_fields(). emqx_connector_schema_lib:ssl_fields().
internal_pool_size(type) -> integer();
internal_pool_size(desc) -> "Pool size on start.";
internal_pool_size(default) -> 1;
internal_pool_size(validator) -> [?MIN(1)];
internal_pool_size(_) -> undefined.
%% =================================================================== %% ===================================================================
on_start(InstId, Config = #{mongo_type := Type, on_start(InstId, Config = #{mongo_type := Type,

View File

@ -34,7 +34,7 @@
]). ]).
-type database() :: binary(). -type database() :: binary().
-type pool_size() :: integer(). -type pool_size() :: pos_integer().
-type username() :: binary(). -type username() :: binary().
-type password() :: binary(). -type password() :: binary().
@ -72,7 +72,7 @@ database(required) -> true;
database(validator) -> [?NOT_EMPTY("the value of the field 'database' cannot be empty")]; database(validator) -> [?NOT_EMPTY("the value of the field 'database' cannot be empty")];
database(_) -> undefined. database(_) -> undefined.
pool_size(type) -> integer(); pool_size(type) -> pos_integer();
pool_size(desc) -> "Size of the connection pool."; pool_size(desc) -> "Size of the connection pool.";
pool_size(default) -> 8; pool_size(default) -> 8;
pool_size(validator) -> [?MIN(1)]; pool_size(validator) -> [?MIN(1)];

View File

@ -93,7 +93,7 @@ topic filters for 'remote_topic' of ingress connections.
"messages in case of ACK not received.", "messages in case of ACK not received.",
#{default => "15s"})} #{default => "15s"})}
, {max_inflight, , {max_inflight,
sc(integer(), sc(non_neg_integer(),
#{ default => 32 #{ default => 32
, desc => "Max inflight (sent, but un-acked) messages of the MQTT protocol" , desc => "Max inflight (sent, but un-acked) messages of the MQTT protocol"
})} })}

View File

@ -127,7 +127,7 @@ namespace() -> "public".
fields(page) -> fields(page) ->
Desc = <<"Page number of the results to fetch.">>, Desc = <<"Page number of the results to fetch.">>,
Meta = #{in => query, desc => Desc, default => 1, example => 1}, Meta = #{in => query, desc => Desc, default => 1, example => 1},
[{page, hoconsc:mk(integer(), Meta)}]; [{page, hoconsc:mk(pos_integer(), Meta)}];
fields(limit) -> fields(limit) ->
Desc = iolist_to_binary([ Desc = iolist_to_binary([
<<"Results per page(max ">>, <<"Results per page(max ">>,

View File

@ -50,55 +50,36 @@ fields(exhook) ->
)} )}
]; ];
fields(server) -> fields(server) ->
[ [ {name, sc(binary(),
{name, #{ desc => "Name of the exhook server."
sc( })}
binary(), , {enable, sc(boolean(),
#{desc => "Name of the exhook server."} #{ default => true
)}, , desc => "Enable the exhook server."
{enable, })}
sc( , {url, sc(binary(),
boolean(), #{ desc => "URL of the gRPC server."
#{ })}
default => true, , {request_timeout, sc(duration(),
desc => "Enable the exhook server." #{ default => "5s"
} , desc => "The timeout to request gRPC server."
)}, })}
{url, , {failed_action, failed_action()}
sc( , {ssl,
binary(), sc(ref(ssl_conf), #{})}
#{desc => "URL of the gRPC server."} , {auto_reconnect,
)}, sc(hoconsc:union([false, duration()]),
{request_timeout, #{ default => "60s"
sc( , desc => "Whether to automatically reconnect (initialize) the gRPC server.<br/>"
duration(), "When gRPC is not available, exhook tries to request the gRPC service at "
#{ "that interval and reinitialize the list of mounted hooks."
default => "5s", })}
desc => "The timeout to request gRPC server." , {pool_size,
} sc(pos_integer(),
)}, #{ default => 8
{failed_action, failed_action()}, , example => 8
{ssl, sc(ref(ssl_conf), #{})}, , desc => "The process pool size for gRPC client."
{auto_reconnect, })}
sc(
hoconsc:union([false, duration()]),
#{
default => "60s",
desc =>
"Whether to automatically reconnect (initialize) the gRPC server.<br/>"
"When gRPC is not available, exhook tries to request the gRPC service at "
"that interval and reinitialize the list of mounted hooks."
}
)},
{pool_size,
sc(
integer(),
#{
default => 8,
example => 8,
desc => "The process pool size for gRPC client."
}
)}
]; ];
fields(ssl_conf) -> fields(ssl_conf) ->
Schema = emqx_schema:client_ssl_opts_schema(#{}), Schema = emqx_schema:client_ssl_opts_schema(#{}),

View File

@ -384,7 +384,7 @@ params_paging_in_qs() ->
[ [
{page, {page,
mk( mk(
integer(), pos_integer(),
#{ #{
in => query, in => query,
required => false, required => false,
@ -394,7 +394,7 @@ params_paging_in_qs() ->
)}, )},
{limit, {limit,
mk( mk(
integer(), pos_integer(),
#{ #{
in => query, in => query,
required => false, required => false,

View File

@ -664,7 +664,7 @@ params_paging() ->
[ [
{page, {page,
mk( mk(
integer(), pos_integer(),
#{ #{
in => query, in => query,
required => false, required => false,
@ -674,7 +674,7 @@ params_paging() ->
)}, )},
{limit, {limit,
mk( mk(
integer(), pos_integer(),
#{ #{
in => query, in => query,
desc => <<"Page Limit">>, desc => <<"Page Limit">>,

View File

@ -191,7 +191,7 @@ users(get, #{bindings := #{name := Name0, id := Id}, query_string := Qs}) ->
Name0, Name0,
Id, Id,
fun(_GwName, #{id := AuthId, chain_name := ChainName}) -> fun(_GwName, #{id := AuthId, chain_name := ChainName}) ->
emqx_authn_api:list_users(ChainName, AuthId, page_pramas(Qs)) emqx_authn_api:list_users(ChainName, AuthId, page_params(Qs))
end end
); );
users(post, #{ users(post, #{
@ -261,7 +261,7 @@ import_users(post, #{
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Utils %% Utils
page_pramas(Qs) -> page_params(Qs) ->
maps:with([<<"page">>, <<"limit">>], Qs). maps:with([<<"page">>, <<"limit">>], Qs).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -555,7 +555,7 @@ params_paging_in_qs() ->
[ [
{page, {page,
mk( mk(
integer(), pos_integer(),
#{ #{
in => query, in => query,
required => false, required => false,
@ -565,7 +565,7 @@ params_paging_in_qs() ->
)}, )},
{limit, {limit,
mk( mk(
integer(), pos_integer(),
#{ #{
in => query, in => query,
required => false, required => false,

View File

@ -149,9 +149,9 @@ schema("/mqtt/delayed/messages") ->
[ [
{data, mk(hoconsc:array(ref("message")), #{})}, {data, mk(hoconsc:array(ref("message")), #{})},
{meta, [ {meta, [
{page, mk(integer(), #{})}, {page, mk(pos_integer(), #{})},
{limit, mk(integer(), #{})}, {limit, mk(pos_integer(), #{})},
{count, mk(integer(), #{})} {count, mk(non_neg_integer(), #{})}
]} ]}
] ]
} }

View File

@ -50,8 +50,8 @@ schema(("/slow_subscriptions")) ->
}, },
get => #{tags => [<<"slow subs">>], get => #{tags => [<<"slow subs">>],
description => <<"Get slow topics statistics record data">>, description => <<"Get slow topics statistics record data">>,
parameters => [ {page, mk(integer(), #{in => query})} parameters => [ {page, mk(pos_integer(), #{in => query})}
, {limit, mk(integer(), #{in => query})} , {limit, mk(pos_integer(), #{in => query})}
], ],
'requestBody' => [], 'requestBody' => [],
responses => #{200 => [{data, mk(hoconsc:array(ref(record)), #{})}]} responses => #{200 => [{data, mk(hoconsc:array(ref(record)), #{})}]}

View File

@ -96,7 +96,7 @@ t_get_history(_) ->
lists:foreach(Each, lists:seq(1, 5)), lists:foreach(Each, lists:seq(1, 5)),
{ok, Data} = request_api(get, api_path(["slow_subscriptions"]), "_page=1&_limit=10", {ok, Data} = request_api(get, api_path(["slow_subscriptions"]), "page=1&limit=10",
auth_header_()), auth_header_()),
#{<<"data">> := [First | _]} = emqx_json:decode(Data, [return_maps]), #{<<"data">> := [First | _]} = emqx_json:decode(Data, [return_maps]),

View File

@ -47,7 +47,7 @@
[ {lc, {git, "https://github.com/emqx/lc.git", {tag, "0.2.1"}}} [ {lc, {git, "https://github.com/emqx/lc.git", {tag, "0.2.1"}}}
, {redbug, "2.0.7"} , {redbug, "2.0.7"}
, {gpb, "4.11.2"} %% gpb only used to build, but not for release, pin it here to avoid fetching a wrong version due to rebar plugins scattered in all the deps , {gpb, "4.11.2"} %% gpb only used to build, but not for release, pin it here to avoid fetching a wrong version due to rebar plugins scattered in all the deps
, {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.8.6"}}} , {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.0"}}}
, {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.12"}}} , {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.12"}}}
, {gproc, {git, "https://github.com/uwiger/gproc", {tag, "0.8.0"}}} , {gproc, {git, "https://github.com/uwiger/gproc", {tag, "0.8.0"}}}
, {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}} , {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}