fix(quic): overload protection follows zone config
This commit is contained in:
parent
3df86508bc
commit
ecf0c8d7e2
|
@ -39,9 +39,9 @@ init(ConnOpts) when is_map(ConnOpts) ->
|
||||||
ConnOpts.
|
ConnOpts.
|
||||||
|
|
||||||
-spec new_conn(quicer:connection_handler(), cb_state()) -> {ok, cb_state()} | {error, any()}.
|
-spec new_conn(quicer:connection_handler(), cb_state()) -> {ok, cb_state()} | {error, any()}.
|
||||||
new_conn(Conn, S) ->
|
new_conn(Conn, #{zone := Zone} = S) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
case emqx_olp:is_overloaded() of
|
case emqx_olp:is_overloaded() andalso is_zone_olp_enabled(Zone) of
|
||||||
false ->
|
false ->
|
||||||
{ok, Pid} = emqx_connection:start_link(emqx_quic_stream, {self(), Conn}, S),
|
{ok, Pid} = emqx_connection:start_link(emqx_quic_stream, {self(), Conn}, S),
|
||||||
receive
|
receive
|
||||||
|
@ -67,3 +67,12 @@ connected(_Conn, S) ->
|
||||||
shutdown(Conn, S) ->
|
shutdown(Conn, S) ->
|
||||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
||||||
{ok, S}.
|
{ok, S}.
|
||||||
|
|
||||||
|
-spec is_zone_olp_enabled(emqx_types:zone()) -> boolean().
|
||||||
|
is_zone_olp_enabled(Zone) ->
|
||||||
|
case emqx_config:get_zone_conf(Zone, [overload_protection]) of
|
||||||
|
#{enable := true} ->
|
||||||
|
true;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue