Commit 959a883f by 雷紫添

增加限流空置。

parent c4cafd64
......@@ -46,7 +46,7 @@ public class RateLimiterAspect {
RATE_LIMITER_CACHE.put(method.getName(), com.google.common.util.concurrent.RateLimiter.create(qps));
}
log.debug("【{}】的QPS设置为: {}", method.getName(), RATE_LIMITER_CACHE.get(method.getName()).getRate());
// log.debug("【{}】的QPS设置为: {}", method.getName(), RATE_LIMITER_CACHE.get(method.getName()).getRate());
// 尝试获取令牌
if (RATE_LIMITER_CACHE.get(method.getName()) != null && !RATE_LIMITER_CACHE.get(method.getName()).tryAcquire(rateLimiter.timeout(), rateLimiter.timeUnit())) {
throw new RuntimeException("手速太快了,慢点儿吧~");
......
......@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@RateLimiter(value = 1.0, timeout = 300)
@RateLimiter(value = 0.1)
@GetMapping("/test1")
public Dict test1() {
log.info("【test1】被执行了。。。。。");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment