Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-api-report
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
雷紫添
xzxt-api-report
Commits
959a883f
Commit
959a883f
authored
Dec 16, 2020
by
雷紫添
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加限流空置。
parent
c4cafd64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
src/main/java/com/founder/ratelimit/guava/aspect/RateLimiterAspect.java
+1
-1
src/main/java/com/founder/ratelimit/guava/controller/TestController.java
+1
-1
No files found.
src/main/java/com/founder/ratelimit/guava/aspect/RateLimiterAspect.java
View file @
959a883f
...
...
@@ -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
(
"手速太快了,慢点儿吧~"
);
...
...
src/main/java/com/founder/ratelimit/guava/controller/TestController.java
View file @
959a883f
...
...
@@ -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】被执行了。。。。。"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment