feat: change mqtt.max_packet_size type from string to bytesize
This commit is contained in:
parent
b8d3dcf59a
commit
e10f9e5e9b
|
@ -46,7 +46,6 @@
|
|||
-type timeout_duration_s() :: 0..?MAX_INT_TIMEOUT_S.
|
||||
-type timeout_duration_ms() :: 0..?MAX_INT_TIMEOUT_MS.
|
||||
-type bytesize() :: integer().
|
||||
-type mqtt_max_packet_size() :: 1..?MAX_INT_MQTT_PACKET_SIZE.
|
||||
-type wordsize() :: bytesize().
|
||||
-type percent() :: float().
|
||||
-type file() :: string().
|
||||
|
@ -73,7 +72,6 @@
|
|||
-typerefl_from_string({timeout_duration_s/0, emqx_schema, to_timeout_duration_s}).
|
||||
-typerefl_from_string({timeout_duration_ms/0, emqx_schema, to_timeout_duration_ms}).
|
||||
-typerefl_from_string({bytesize/0, emqx_schema, to_bytesize}).
|
||||
-typerefl_from_string({mqtt_max_packet_size/0, emqx_schema, to_bytesize}).
|
||||
-typerefl_from_string({wordsize/0, emqx_schema, to_wordsize}).
|
||||
-typerefl_from_string({percent/0, emqx_schema, to_percent}).
|
||||
-typerefl_from_string({comma_separated_list/0, emqx_schema, to_comma_separated_list}).
|
||||
|
@ -93,6 +91,7 @@
|
|||
|
||||
-export([
|
||||
validate_heap_size/1,
|
||||
validate_packet_size/1,
|
||||
user_lookup_fun_tr/2,
|
||||
validate_alarm_actions/1,
|
||||
validate_keepalive_multiplier/1,
|
||||
|
@ -154,7 +153,6 @@
|
|||
timeout_duration_s/0,
|
||||
timeout_duration_ms/0,
|
||||
bytesize/0,
|
||||
mqtt_max_packet_size/0,
|
||||
wordsize/0,
|
||||
percent/0,
|
||||
file/0,
|
||||
|
@ -2618,6 +2616,16 @@ validate_heap_size(Siz) when is_integer(Siz) ->
|
|||
validate_heap_size(_SizStr) ->
|
||||
{error, invalid_heap_size}.
|
||||
|
||||
validate_packet_size(Siz) when is_integer(Siz) andalso Siz < 1 ->
|
||||
{error, #{reason => max_heap_size_too_small, minimum => 1}};
|
||||
validate_packet_size(Siz) when is_integer(Siz) andalso Siz > ?MAX_INT_MQTT_PACKET_SIZE ->
|
||||
Max = integer_to_list(round(?MAX_INT_MQTT_PACKET_SIZE / 1024 / 1024)) ++ "M",
|
||||
{error, #{reason => max_heap_size_too_large, maximum => Max}};
|
||||
validate_packet_size(Siz) when is_integer(Siz) ->
|
||||
ok;
|
||||
validate_packet_size(_SizStr) ->
|
||||
{error, invalid_packet_size}.
|
||||
|
||||
validate_keepalive_multiplier(Multiplier) when
|
||||
is_number(Multiplier) andalso Multiplier >= 1.0 andalso Multiplier =< 65535.0
|
||||
->
|
||||
|
@ -3380,9 +3388,10 @@ mqtt_general() ->
|
|||
)},
|
||||
{"max_packet_size",
|
||||
sc(
|
||||
mqtt_max_packet_size(),
|
||||
bytesize(),
|
||||
#{
|
||||
default => <<"1MB">>,
|
||||
validator => fun ?MODULE:validate_packet_size/1,
|
||||
desc => ?DESC(mqtt_max_packet_size)
|
||||
}
|
||||
)},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{application, emqx_dashboard, [
|
||||
{description, "EMQX Web Dashboard"},
|
||||
% strict semver, bump manually!
|
||||
{vsn, "5.0.25"},
|
||||
{vsn, "5.0.26"},
|
||||
{modules, []},
|
||||
{registered, [emqx_dashboard_sup]},
|
||||
{applications, [kernel, stdlib, mnesia, minirest, emqx, emqx_ctl, emqx_bridge_http]},
|
||||
|
@ -12,6 +12,6 @@
|
|||
{maintainers, ["EMQX Team <contact@emqx.io>"]},
|
||||
{links, [
|
||||
{"Homepage", "https://emqx.io/"},
|
||||
{"Github", "https://github.com/emqx/emqx-dashboard"}
|
||||
{"Github", "https://github.com/emqx/emqx-dashboard5"}
|
||||
]}
|
||||
]}.
|
||||
|
|
|
@ -856,8 +856,6 @@ typename_to_spec("timeout()", _Mod) ->
|
|||
};
|
||||
typename_to_spec("bytesize()", _Mod) ->
|
||||
#{type => string, example => <<"32MB">>};
|
||||
typename_to_spec("mqtt_max_packet_size()", _Mod) ->
|
||||
#{type => string, example => <<"32MB">>};
|
||||
typename_to_spec("wordsize()", _Mod) ->
|
||||
#{type => string, example => <<"1024KB">>};
|
||||
typename_to_spec("map()", _Mod) ->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_opentelemetry, [
|
||||
{description, "OpenTelemetry for EMQX Broker"},
|
||||
{vsn, "0.1.0"},
|
||||
{vsn, "0.1.1"},
|
||||
{registered, []},
|
||||
{mod, {emqx_otel_app, []}},
|
||||
{applications, [kernel, stdlib, emqx]},
|
||||
|
|
|
@ -150,9 +150,9 @@ get_vm_gauge(Name) ->
|
|||
[{emqx_mgmt:vm_stats(Name), #{}}].
|
||||
|
||||
get_cluster_gauge('node.running') ->
|
||||
length(emqx:cluster_nodes(running));
|
||||
[{length(emqx:cluster_nodes(running)), #{}}];
|
||||
get_cluster_gauge('node.stopped') ->
|
||||
length(emqx:cluster_nodes(stopped)).
|
||||
[{length(emqx:cluster_nodes(stopped)), #{}}].
|
||||
|
||||
get_metric_counter(Name) ->
|
||||
[{emqx_metrics:val(Name), #{}}].
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Changed the type of the `mqtt.mqx_packet_size` from string to byteSize to better represent the valid numeric range.
|
||||
Strings will still be accepted for backwards compatibility.
|
|
@ -1369,7 +1369,7 @@ sysmon_vm_process_low_watermark.label:
|
|||
"""Process low watermark"""
|
||||
|
||||
mqtt_max_packet_size.desc:
|
||||
"""Maximum MQTT packet size allowed."""
|
||||
"""Maximum MQTT packet size allowed. Default: 1MB, Maximum: 256MB"""
|
||||
|
||||
mqtt_max_packet_size.label:
|
||||
"""Max Packet Size"""
|
||||
|
|
Loading…
Reference in New Issue