fix(doc): Update the documentation/keepalive according to the review.

This commit is contained in:
zhongwencool 2022-01-27 18:57:35 +08:00
parent 3ce3c5c805
commit a7676d0163
4 changed files with 24 additions and 16 deletions

View File

@ -1670,7 +1670,8 @@ ensure_keepalive_timer(0, Channel) -> Channel;
ensure_keepalive_timer(disabled, Channel) -> Channel; ensure_keepalive_timer(disabled, Channel) -> Channel;
ensure_keepalive_timer(Interval, Channel = #channel{clientinfo = #{zone := Zone}}) -> ensure_keepalive_timer(Interval, Channel = #channel{clientinfo = #{zone := Zone}}) ->
Backoff = get_mqtt_conf(Zone, keepalive_backoff), Backoff = get_mqtt_conf(Zone, keepalive_backoff),
Keepalive = emqx_keepalive:init(round(timer:seconds(Interval) * Backoff)), RecvOct = emqx_pd:get_counter(incoming_bytes),
Keepalive = emqx_keepalive:init(RecvOct, round(timer:seconds(Interval) * Backoff)),
ensure_timer(alive_timer, Channel#channel{keepalive = Keepalive}). ensure_timer(alive_timer, Channel#channel{keepalive = Keepalive}).
clear_keepalive(Channel = #channel{timers = Timers}) -> clear_keepalive(Channel = #channel{timers = Timers}) ->

View File

@ -17,6 +17,7 @@
-module(emqx_keepalive). -module(emqx_keepalive).
-export([ init/1 -export([ init/1
, init/2
, info/1 , info/1
, info/2 , info/2
, check/2 , check/2
@ -37,9 +38,13 @@
%% @doc Init keepalive. %% @doc Init keepalive.
-spec(init(Interval :: non_neg_integer()) -> keepalive()). -spec(init(Interval :: non_neg_integer()) -> keepalive()).
init(Interval) when Interval > 0 -> init(Interval) -> init(0, Interval).
%% @doc Init keepalive.
-spec(init(StatVal :: non_neg_integer(), Interval :: non_neg_integer()) -> keepalive()).
init(StatVal, Interval) when Interval > 0 ->
#keepalive{interval = Interval, #keepalive{interval = Interval,
statval = emqx_pd:get_counter(incoming_bytes), statval = StatVal,
repeat = 0}. repeat = 0}.
%% @doc Get Info of the keepalive. %% @doc Get Info of the keepalive.

View File

@ -157,7 +157,7 @@ roots(low) ->
sc(ref("force_gc"), sc(ref("force_gc"),
#{ desc => #{ desc =>
"""Force the MQTT connection process garbage collection after """Force the MQTT connection process garbage collection after
this number of messages or bytes passed through.""" this number of messages or bytes have passed through."""
})} })}
, {"conn_congestion", , {"conn_congestion",
sc(ref("conn_congestion"), sc(ref("conn_congestion"),
@ -334,17 +334,17 @@ message within this interval."""
, {"shared_subscription", , {"shared_subscription",
sc(boolean(), sc(boolean(),
#{ default => true, #{ default => true,
desc => "Support MQTT Shared Subscriptions" desc => "Support MQTT Shared Subscriptions."
})} })}
, {"ignore_loop_deliver", , {"ignore_loop_deliver",
sc(boolean(), sc(boolean(),
#{ default => false, #{ default => false,
desc => "Ignore loop delivery of messages for mqtt v3.1.1" desc => "Ignore loop delivery of messages for mqtt v3.1.1."
})} })}
, {"strict_mode", , {"strict_mode",
sc(boolean(), sc(boolean(),
#{default => false, #{default => false,
desc => "Parse the MQTT frame in strict mode" desc => "Parse the MQTT frame in strict mode."
}) })
} }
, {"response_information", , {"response_information",
@ -358,7 +358,10 @@ This feature is disabled if is set to \"\"."""
, {"server_keepalive", , {"server_keepalive",
sc(hoconsc:union([integer(), disabled]), sc(hoconsc:union([integer(), disabled]),
#{ default => disabled, #{ default => disabled,
desc => "Server Keep Alive of MQTT 5.0" desc =>
"""Server Keep Alive of MQTT 5.0.
If the Server returns a Server Keep Alive on the CONNACK packet,
the Client MUST use that value instead of the value it sent as the Keep Alive."""
}) })
} }
, {"keepalive_backoff", , {"keepalive_backoff",
@ -378,7 +381,7 @@ after idling for 'Keepalive * backoff * 2'."""
, {"upgrade_qos", , {"upgrade_qos",
sc(boolean(), sc(boolean(),
#{ default => false, #{ default => false,
desc => "Force to upgrade QoS according to subscription." desc => "Force upgrade of QoS level according to subscription."
}) })
} }
, {"max_inflight", , {"max_inflight",
@ -427,9 +430,9 @@ or inflight window is full."""
There's no priority table by default, hence all messages are treated equal.<br> There's no priority table by default, hence all messages are treated equal.<br>
Priority number [1-255]<br> Priority number [1-255]<br>
**NOTE**: Comma and equal signs are not allowed for priority topic names<br> **NOTE**: Comma and equal signs are not allowed for priority topic names.<br>
**NOTE**: Messages for topics not in the priority table are treated as **NOTE**: Messages for topics not in the priority table are treated as
either highest or lowest priority depending on the configured value for mqtt.mqueue_default_priority either highest or lowest priority depending on the configured value for mqtt.mqueue_default_priority.
<br><br> <br><br>
**Examples**: **Examples**:
To configure \"topic/1\" > \"topic/2\": To configure \"topic/1\" > \"topic/2\":
@ -439,7 +442,7 @@ mqueue_priorities: {\"topic/1\": 10, \"topic/2\": 8}"""
, {"mqueue_default_priority", , {"mqueue_default_priority",
sc(hoconsc:enum([highest, lowest]), sc(hoconsc:enum([highest, lowest]),
#{ default => lowest, #{ default => lowest,
desc => "Default to highest priority for topics not matching priority table" desc => "Default to highest priority for topics not matching priority table."
}) })
} }
, {"mqueue_store_qos0", , {"mqueue_store_qos0",
@ -451,7 +454,7 @@ mqueue_priorities: {\"topic/1\": 10, \"topic/2\": 8}"""
, {"use_username_as_clientid", , {"use_username_as_clientid",
sc(boolean(), sc(boolean(),
#{ default => false, #{ default => false,
desc => "Replace client id with the username" desc => "Replace client id with the username."
}) })
} }
, {"peer_cert_as_username", , {"peer_cert_as_username",
@ -587,12 +590,12 @@ fields("force_gc") ->
, {"count", , {"count",
sc(range(0, inf), sc(range(0, inf),
#{ default => 16000, #{ default => 16000,
desc => "GC the process after this many received messages" desc => "GC the process after this many received messages."
})} })}
, {"bytes", , {"bytes",
sc(bytesize(), sc(bytesize(),
#{ default => "16MB", #{ default => "16MB",
desc => "GC the process after how much bytes passed through" desc => "GC the process after specified number of bytes have passed through."
})} })}
]; ];

View File

@ -39,4 +39,3 @@ t_check(_) ->
?assertEqual(1, emqx_keepalive:info(statval, Keepalive2)), ?assertEqual(1, emqx_keepalive:info(statval, Keepalive2)),
?assertEqual(1, emqx_keepalive:info(repeat, Keepalive2)), ?assertEqual(1, emqx_keepalive:info(repeat, Keepalive2)),
?assertEqual({error, timeout}, emqx_keepalive:check(1, Keepalive2)). ?assertEqual({error, timeout}, emqx_keepalive:check(1, Keepalive2)).