|
@@ -42,7 +42,9 @@ public class ApiFlowLimitedInterceptor implements HandlerInterceptor {
|
|
|
|
|
|
private static final RateLimiter rateLimiter;
|
|
|
|
|
|
- private static boolean enable;
|
|
|
+ private static boolean enable = true;
|
|
|
+
|
|
|
+ private static int allowedRate = 0;
|
|
|
|
|
|
private static Properties props = new Properties();
|
|
|
|
|
@@ -52,6 +54,7 @@ public class ApiFlowLimitedInterceptor implements HandlerInterceptor {
|
|
|
rateLimiter = RateLimiter.create(permitsPerSecond);
|
|
|
|
|
|
enable = PropertyHolder.getBoolean("examcloud.api.flowLimited.enable", true);
|
|
|
+ allowedRate = PropertyHolder.getInt("examcloud.api.flowLimited.allowedRate", 5);
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
@Override
|
|
@@ -135,9 +138,9 @@ public class ApiFlowLimitedInterceptor implements HandlerInterceptor {
|
|
|
}
|
|
|
if (limited) {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
int random = RandomUtils.nextInt(100);
|
|
|
- if (random <= 10) {
|
|
|
+ if (random <= allowedRate) {
|
|
|
return true;
|
|
|
}
|
|
|
|