public class RateLimiterUtil extends Object
| Constructor and Description |
|---|
RateLimiterUtil() |
| Modifier and Type | Method and Description |
|---|---|
static com.google.common.util.concurrent.RateLimiter |
create(double permitsPerSecond,
double maxBurstSeconds)
一个用来定制RateLimiter的方法,默认一开始就桶里就装满token。
|
static com.google.common.util.concurrent.RateLimiter |
create(double permitsPerSecond,
double maxBurstSeconds,
boolean filledWithToken)
一个用来定制RateLimiter的方法。
|
public static com.google.common.util.concurrent.RateLimiter create(double permitsPerSecond,
double maxBurstSeconds)
throws ReflectiveOperationException
permitsPerSecond - 每秒允许的请求数,可看成QPS。maxBurstSeconds - 可看成桶的容量,Guava中最大的突发流量缓冲时间,默认是1s, permitsPerSecond * maxBurstSeconds,就是闲置时累积的缓冲token最大值。ReflectiveOperationExceptionpublic static com.google.common.util.concurrent.RateLimiter create(double permitsPerSecond,
double maxBurstSeconds,
boolean filledWithToken)
throws ReflectiveOperationException
permitsPerSecond - 每秒允许的请求书,可看成QPSmaxBurstSeconds - 最大的突发缓冲时间。用来应对突发流量。Guava的实现默认是1s。permitsPerSecond * maxBurstSeconds的数量,就是闲置时预留的缓冲token数量filledWithToken - 是否需要创建时就保留有permitsPerSecond * maxBurstSeconds的tokenReflectiveOperationExceptionCopyright © 2018. All rights reserved.