Merge pull request #7669 from lafirest/feat/chinese_desc_api_check_slow_subs
feat(slow_subs): add i18n support
This commit is contained in:
commit
2ea539bfc3
|
@ -0,0 +1,66 @@
|
||||||
|
emqx_slow_subs_api {
|
||||||
|
|
||||||
|
clear_records_api {
|
||||||
|
desc {
|
||||||
|
en: "Clear current data and re count slow topic"
|
||||||
|
zh: "清除当前记录,然后重新开始统计"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get_records_api {
|
||||||
|
desc {
|
||||||
|
en: "View slow topics statistics record data"
|
||||||
|
zh: "查看慢订阅的统计数据"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get_setting_api {
|
||||||
|
desc {
|
||||||
|
en: "View slow subs settings"
|
||||||
|
zh: "查看配置"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update_setting_api {
|
||||||
|
desc {
|
||||||
|
en: "Update slow subs settings"
|
||||||
|
zh: "更新配置"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clientid {
|
||||||
|
desc {
|
||||||
|
en: "Message clientid"
|
||||||
|
zh: "消息的客户端 ID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
node {
|
||||||
|
desc {
|
||||||
|
en: "Message node name"
|
||||||
|
zh: "消息的节点名称"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
topic {
|
||||||
|
desc {
|
||||||
|
en: "Message topic"
|
||||||
|
zh: "消息的主题"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timespan {
|
||||||
|
desc {
|
||||||
|
en: "Timespan for message transmission"
|
||||||
|
zh: "消息的传输耗时"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
last_update_time {
|
||||||
|
desc {
|
||||||
|
en: "The timestamp of last update"
|
||||||
|
zh: "记录的更新时间戳"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
emqx_slow_subs_schema {
|
||||||
|
|
||||||
|
enable {
|
||||||
|
desc {
|
||||||
|
en: "Enable this feature"
|
||||||
|
zh: "开启慢订阅"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
threshold {
|
||||||
|
desc {
|
||||||
|
en: "The latency threshold for statistics"
|
||||||
|
zh: "慢订阅统计的阈值"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expire_interval {
|
||||||
|
desc {
|
||||||
|
en: "The eviction time of the record, which in the statistics record table"
|
||||||
|
zh: "慢订阅记录的有效时间"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
top_k_num {
|
||||||
|
desc {
|
||||||
|
en: "The maximum number of records in the slow subscription statistics record table"
|
||||||
|
zh: "慢订阅统计表的记录数量上限"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stats_type {
|
||||||
|
desc {
|
||||||
|
en: "The method to calculate the latency"
|
||||||
|
zh: "慢订阅的统计类型"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -20,12 +20,13 @@
|
||||||
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
-include_lib("emqx_slow_subs/include/emqx_slow_subs.hrl").
|
-include_lib("emqx_slow_subs/include/emqx_slow_subs.hrl").
|
||||||
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
|
|
||||||
-export([api_spec/0, paths/0, schema/1, fields/1, namespace/0]).
|
-export([api_spec/0, paths/0, schema/1, fields/1, namespace/0]).
|
||||||
|
|
||||||
-export([slow_subs/2, get_history/0, settings/2]).
|
-export([slow_subs/2, get_history/0, settings/2]).
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, ref/1]).
|
-import(hoconsc, [mk/2, ref/1, ref/2]).
|
||||||
-import(emqx_mgmt_util, [bad_request/0]).
|
-import(emqx_mgmt_util, [bad_request/0]).
|
||||||
|
|
||||||
-define(APP, emqx_slow_subs).
|
-define(APP, emqx_slow_subs).
|
||||||
|
@ -44,17 +45,17 @@ schema(("/slow_subscriptions")) ->
|
||||||
'operationId' => slow_subs,
|
'operationId' => slow_subs,
|
||||||
delete => #{
|
delete => #{
|
||||||
tags => [<<"slow subs">>],
|
tags => [<<"slow subs">>],
|
||||||
description => <<"Clear current data and re count slow topic">>,
|
description => ?DESC(clear_records_api),
|
||||||
parameters => [],
|
parameters => [],
|
||||||
'requestBody' => [],
|
'requestBody' => [],
|
||||||
responses => #{204 => <<"No Content">>}
|
responses => #{204 => <<"No Content">>}
|
||||||
},
|
},
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"slow subs">>],
|
tags => [<<"slow subs">>],
|
||||||
description => <<"Get slow topics statistics record data">>,
|
description => ?DESC(get_records_api),
|
||||||
parameters => [
|
parameters => [
|
||||||
{page, mk(pos_integer(), #{in => query})},
|
ref(emqx_dashboard_swagger, page),
|
||||||
{limit, mk(pos_integer(), #{in => query})}
|
ref(emqx_dashboard_swagger, limit)
|
||||||
],
|
],
|
||||||
'requestBody' => [],
|
'requestBody' => [],
|
||||||
responses => #{200 => [{data, mk(hoconsc:array(ref(record)), #{})}]}
|
responses => #{200 => [{data, mk(hoconsc:array(ref(record)), #{})}]}
|
||||||
|
@ -65,12 +66,12 @@ schema("/slow_subscriptions/settings") ->
|
||||||
'operationId' => settings,
|
'operationId' => settings,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"slow subs">>],
|
tags => [<<"slow subs">>],
|
||||||
description => <<"Get slow subs settings">>,
|
description => ?DESC(get_setting_api),
|
||||||
responses => #{200 => conf_schema()}
|
responses => #{200 => conf_schema()}
|
||||||
},
|
},
|
||||||
put => #{
|
put => #{
|
||||||
tags => [<<"slow subs">>],
|
tags => [<<"slow subs">>],
|
||||||
description => <<"Update slow subs settings">>,
|
description => ?DESC(update_setting_api),
|
||||||
'requestBody' => conf_schema(),
|
'requestBody' => conf_schema(),
|
||||||
responses => #{200 => conf_schema()}
|
responses => #{200 => conf_schema()}
|
||||||
}
|
}
|
||||||
|
@ -78,15 +79,15 @@ schema("/slow_subscriptions/settings") ->
|
||||||
|
|
||||||
fields(record) ->
|
fields(record) ->
|
||||||
[
|
[
|
||||||
{clientid, mk(string(), #{desc => <<"the clientid">>})},
|
{clientid, mk(string(), #{desc => ?DESC(clientid)})},
|
||||||
{node, mk(string(), #{desc => <<"the node">>})},
|
{node, mk(string(), #{desc => ?DESC(node)})},
|
||||||
{topic, mk(string(), #{desc => <<"the topic">>})},
|
{topic, mk(string(), #{desc => ?DESC(topic)})},
|
||||||
{timespan,
|
{timespan,
|
||||||
mk(
|
mk(
|
||||||
integer(),
|
integer(),
|
||||||
#{desc => <<"timespan for message transmission">>}
|
#{desc => ?DESC(timespan)}
|
||||||
)},
|
)},
|
||||||
{last_update_time, mk(integer(), #{desc => <<"the timestamp of last update">>})}
|
{last_update_time, mk(integer(), #{desc => ?DESC(last_update_time)})}
|
||||||
].
|
].
|
||||||
|
|
||||||
conf_schema() ->
|
conf_schema() ->
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
-module(emqx_slow_subs_schema).
|
-module(emqx_slow_subs_schema).
|
||||||
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
|
|
||||||
-export([roots/0, fields/1, desc/1, namespace/0]).
|
-export([roots/0, fields/1, desc/1, namespace/0]).
|
||||||
|
|
||||||
|
@ -10,30 +11,30 @@ roots() -> ["slow_subs"].
|
||||||
|
|
||||||
fields("slow_subs") ->
|
fields("slow_subs") ->
|
||||||
[
|
[
|
||||||
{enable, sc(boolean(), false, "Enable this feature.")},
|
{enable, sc(boolean(), false, enable)},
|
||||||
{threshold,
|
{threshold,
|
||||||
sc(
|
sc(
|
||||||
emqx_schema:duration_ms(),
|
emqx_schema:duration_ms(),
|
||||||
"500ms",
|
"500ms",
|
||||||
"The latency threshold for statistics, the minimum value is 100ms."
|
threshold
|
||||||
)},
|
)},
|
||||||
{expire_interval,
|
{expire_interval,
|
||||||
sc(
|
sc(
|
||||||
emqx_schema:duration_ms(),
|
emqx_schema:duration_ms(),
|
||||||
"300s",
|
"300s",
|
||||||
"The eviction time of the record, which in the statistics record table."
|
expire_interval
|
||||||
)},
|
)},
|
||||||
{top_k_num,
|
{top_k_num,
|
||||||
sc(
|
sc(
|
||||||
pos_integer(),
|
pos_integer(),
|
||||||
10,
|
10,
|
||||||
"The maximum number of records in the slow subscription statistics record table."
|
top_k_num
|
||||||
)},
|
)},
|
||||||
{stats_type,
|
{stats_type,
|
||||||
sc(
|
sc(
|
||||||
hoconsc:union([whole, internal, response]),
|
hoconsc:union([whole, internal, response]),
|
||||||
whole,
|
whole,
|
||||||
"The method to calculate the latency."
|
stats_type
|
||||||
)}
|
)}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -46,4 +47,4 @@ desc(_) ->
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
sc(Type, Default, Desc) ->
|
sc(Type, Default, Desc) ->
|
||||||
hoconsc:mk(Type, #{default => Default, desc => Desc}).
|
hoconsc:mk(Type, #{default => Default, desc => ?DESC(Desc)}).
|
||||||
|
|
Loading…
Reference in New Issue