chore: 优化IP访问限制配置的命名
This commit is contained in:
@@ -24,8 +24,8 @@ public interface SystemConstants {
|
||||
String ROOT_ROLE_CODE = "ROOT";
|
||||
|
||||
/**
|
||||
* IP请求限制QPS阈值配置KEY
|
||||
* 单个IP请求的最大每秒查询数(QPS)阈值Key
|
||||
*/
|
||||
String CONFIG_IP_RATE_LIMIT_QPS_KEY = "IP_RATE_LIMIT_COUNT_QPS";
|
||||
String IP_QPS_THRESHOLD_LIMIT_KEY = "IP_QPS_THRESHOLD_LIMIT";
|
||||
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ public class RedisRateLimiterFilter extends OncePerRequestFilter {
|
||||
if (count == null || count == 1) {
|
||||
redisTemplate.expire(key,1, TimeUnit.SECONDS);
|
||||
}
|
||||
Object systemConfig = sysConfigService.getSystemConfig(SystemConstants.CONFIG_IP_RATE_LIMIT_QPS_KEY);
|
||||
Object systemConfig = sysConfigService.getSystemConfig(SystemConstants.IP_QPS_THRESHOLD_LIMIT_KEY);
|
||||
long limit = 10;
|
||||
if(systemConfig != null){
|
||||
limit = Long.parseLong(systemConfig.toString());
|
||||
}else{
|
||||
log.warn("[RedisRateLimiterFilter.rateLimit]系统配置中未配置IP请求限制QPS阈值配置,使用默认值:{},请检查配置项:{}",
|
||||
limit,SystemConstants.CONFIG_IP_RATE_LIMIT_QPS_KEY);
|
||||
limit,SystemConstants.IP_QPS_THRESHOLD_LIMIT_KEY);
|
||||
}
|
||||
return count != null && count > limit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user