Merge pull request #10490 from lafirest/fix/rmv_def_conn_limit

fix(limiter): remove the default limit of connect rate
This commit is contained in:
lafirest 2023-04-24 22:04:29 +08:00 committed by GitHub
commit 2845469c48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 17 deletions

View File

@ -36,11 +36,11 @@
]). ]).
-define(KILOBYTE, 1024). -define(KILOBYTE, 1024).
-define(BUCKET_KEYS, [ -define(LISTENER_BUCKET_KEYS, [
{bytes, bucket_infinity}, bytes,
{messages, bucket_infinity}, messages,
{connection, bucket_limit}, connection,
{message_routing, bucket_infinity} message_routing
]). ]).
-type limiter_type() :: -type limiter_type() ::
@ -132,10 +132,8 @@ fields(node_opts) ->
]; ];
fields(client_fields) -> fields(client_fields) ->
client_fields(types(), #{default => #{}}); client_fields(types(), #{default => #{}});
fields(bucket_infinity) -> fields(bucket_opts) ->
fields_of_bucket(<<"infinity">>); fields_of_bucket(<<"infinity">>);
fields(bucket_limit) ->
fields_of_bucket(<<"1000/s">>);
fields(client_opts) -> fields(client_opts) ->
[ [
{rate, ?HOCON(rate(), #{default => <<"infinity">>, desc => ?DESC(rate)})}, {rate, ?HOCON(rate(), #{default => <<"infinity">>, desc => ?DESC(rate)})},
@ -194,10 +192,9 @@ fields(client_opts) ->
)} )}
]; ];
fields(listener_fields) -> fields(listener_fields) ->
composite_bucket_fields(?BUCKET_KEYS, listener_client_fields); composite_bucket_fields(?LISTENER_BUCKET_KEYS, listener_client_fields);
fields(listener_client_fields) -> fields(listener_client_fields) ->
{Types, _} = lists:unzip(?BUCKET_KEYS), client_fields(?LISTENER_BUCKET_KEYS, #{required => false});
client_fields(Types, #{required => false});
fields(Type) -> fields(Type) ->
simple_bucket_field(Type). simple_bucket_field(Type).
@ -205,10 +202,8 @@ desc(limiter) ->
"Settings for the rate limiter."; "Settings for the rate limiter.";
desc(node_opts) -> desc(node_opts) ->
"Settings for the limiter of the node level."; "Settings for the limiter of the node level.";
desc(bucket_infinity) -> desc(bucket_opts) ->
"Settings for the bucket."; "Settings for the bucket.";
desc(bucket_limit) ->
desc(bucket_infinity);
desc(client_opts) -> desc(client_opts) ->
"Settings for the client in bucket level."; "Settings for the client in bucket level.";
desc(client_fields) -> desc(client_fields) ->
@ -360,7 +355,7 @@ apply_unit(Unit, _) -> throw("invalid unit:" ++ Unit).
%% A bucket with only one type %% A bucket with only one type
simple_bucket_field(Type) when is_atom(Type) -> simple_bucket_field(Type) when is_atom(Type) ->
fields(bucket_infinity) ++ fields(bucket_opts) ++
[ [
{client, {client,
?HOCON( ?HOCON(
@ -378,13 +373,13 @@ simple_bucket_field(Type) when is_atom(Type) ->
composite_bucket_fields(Types, ClientRef) -> composite_bucket_fields(Types, ClientRef) ->
[ [
{Type, {Type,
?HOCON(?R_REF(?MODULE, Opts), #{ ?HOCON(?R_REF(?MODULE, bucket_opts), #{
desc => ?DESC(?MODULE, Type), desc => ?DESC(?MODULE, Type),
required => false, required => false,
importance => importance_of_type(Type), importance => importance_of_type(Type),
aliases => alias_of_type(Type) aliases => alias_of_type(Type)
})} })}
|| {Type, Opts} <- Types || Type <- Types
] ++ ] ++
[ [
{client, {client,

View File

@ -0,0 +1 @@
Remove the default limit of connect rate which used to be `1000/s`