Merge pull request #10800 from lafirest/pref/default_behaviour
fix(limiter): improve the default configuration
This commit is contained in:
commit
592a87d99f
|
@ -110,7 +110,7 @@ roots() ->
|
|||
].
|
||||
|
||||
fields(limiter) ->
|
||||
short_paths_fields(?MODULE) ++
|
||||
short_paths_fields(?MODULE, ?IMPORTANCE_HIDDEN) ++
|
||||
[
|
||||
{Type,
|
||||
?HOCON(?R_REF(node_opts), #{
|
||||
|
@ -181,7 +181,7 @@ fields(client_opts) ->
|
|||
boolean(),
|
||||
#{
|
||||
desc => ?DESC(divisible),
|
||||
default => false,
|
||||
default => true,
|
||||
importance => ?IMPORTANCE_HIDDEN
|
||||
}
|
||||
)},
|
||||
|
@ -190,7 +190,7 @@ fields(client_opts) ->
|
|||
emqx_schema:duration(),
|
||||
#{
|
||||
desc => ?DESC(max_retry_time),
|
||||
default => <<"10s">>,
|
||||
default => <<"1h">>,
|
||||
importance => ?IMPORTANCE_HIDDEN
|
||||
}
|
||||
)},
|
||||
|
@ -212,9 +212,17 @@ fields(Type) ->
|
|||
simple_bucket_field(Type).
|
||||
|
||||
short_paths_fields(DesModule) ->
|
||||
short_paths_fields(DesModule, ?DEFAULT_IMPORTANCE).
|
||||
|
||||
short_paths_fields(DesModule, Importance) ->
|
||||
[
|
||||
{Name,
|
||||
?HOCON(rate(), #{desc => ?DESC(DesModule, Name), required => false, example => Example})}
|
||||
?HOCON(rate(), #{
|
||||
desc => ?DESC(DesModule, Name),
|
||||
required => false,
|
||||
importance => Importance,
|
||||
example => Example
|
||||
})}
|
||||
|| {Name, Example} <-
|
||||
lists:zip(short_paths(), [<<"1000/s">>, <<"1000/s">>, <<"100MB/s">>])
|
||||
].
|
||||
|
@ -280,8 +288,8 @@ default_client_config() ->
|
|||
initial => 0,
|
||||
low_watermark => 0,
|
||||
burst => 0,
|
||||
divisible => false,
|
||||
max_retry_time => timer:seconds(10),
|
||||
divisible => true,
|
||||
max_retry_time => timer:hours(1),
|
||||
failure_strategy => force
|
||||
}.
|
||||
|
||||
|
|
|
@ -746,7 +746,7 @@ t_create_esockd_htb_limiter(_) ->
|
|||
ok.
|
||||
|
||||
t_esockd_htb_consume(_) ->
|
||||
ClientCfg = emqx_limiter_schema:default_client_config(),
|
||||
ClientCfg = default_client_config(),
|
||||
Cfg = #{client => #{bytes => ClientCfg#{rate := 50, max_retry_time := 0}}},
|
||||
Opts = emqx_esockd_htb_limiter:new_create_options(?FUNCTION_NAME, bytes, Cfg),
|
||||
Limiter = emqx_esockd_htb_limiter:create(Opts),
|
||||
|
@ -1067,7 +1067,7 @@ parse_and_check(ConfigString) ->
|
|||
|
||||
make_create_test_data_with_infinity_node(FakeInstnace) ->
|
||||
Infinity = emqx_htb_limiter:make_infinity_limiter(),
|
||||
ClientCfg = emqx_limiter_schema:default_client_config(),
|
||||
ClientCfg = default_client_config(),
|
||||
InfinityRef = emqx_limiter_bucket_ref:infinity_bucket(),
|
||||
MkC = fun(Rate) ->
|
||||
#{client => #{bytes => ClientCfg#{rate := Rate}}}
|
||||
|
@ -1133,3 +1133,7 @@ parse_schema(ConfigString) ->
|
|||
RawConf,
|
||||
#{required => false, atom_key => false}
|
||||
).
|
||||
|
||||
default_client_config() ->
|
||||
Conf = emqx_limiter_schema:default_client_config(),
|
||||
Conf#{divisible := false, max_retry_time := timer:seconds(10)}.
|
||||
|
|
Loading…
Reference in New Issue