From bb5966f1b694737e8c96d6824a2d5093fe58adf3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 11 Apr 2024 22:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91RateLimiter?= =?UTF-8?q?=20=E9=99=90=E6=B5=81=E5=99=A8=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E3=80=81=E7=94=A8=E6=88=B7=E3=80=81IP=20?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E5=88=AB=E7=9A=84=E9=99=90=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- yudao-dependencies/pom.xml | 12 ---- .../pom.xml | 13 ++-- .../idempotent/core/aop/IdempotentAspect.java | 4 +- .../config/YudaoRateLimiterConfiguration.java | 55 ++++++++++++++++ .../core/annotation/RateLimiter.java | 62 ++++++++++++++++++ .../core/aop/RateLimiterAspect.java | 60 +++++++++++++++++ .../keyresolver/RateLimiterKeyResolver.java | 22 +++++++ .../impl/ClientIpRateLimiterKeyResolver.java | 27 ++++++++ .../impl/DefaultRateLimiterKeyResolver.java | 25 ++++++++ .../ExpressionRateLimiterKeyResolver.java | 64 +++++++++++++++++++ .../ServerNodeRateLimiterKeyResolver.java | 27 ++++++++ .../impl/UserRateLimiterKeyResolver.java | 28 ++++++++ .../core/redis/RateLimiterRedisDAO.java | 60 +++++++++++++++++ .../framework/ratelimiter/package-info.java | 4 ++ .../framework/resilience4j/package-info.java | 9 --- ...“ Spring Boot æœåŠ¡å®¹é”™ Resilience4j 入门》.md | 1 - ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../core/handler/GlobalExceptionHandler.java | 30 +++------ .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../application-integration-test.yaml | 10 --- .../test/resources/application-unit-test.yaml | 2 - .../test/resources/application-unit-test.yaml | 2 - .../application-integration-test.yaml | 10 --- .../test/resources/application-unit-test.yaml | 2 - 31 files changed, 453 insertions(+), 95 deletions(-) create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/config/YudaoRateLimiterConfiguration.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/annotation/RateLimiter.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/aop/RateLimiterAspect.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/RateLimiterKeyResolver.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ClientIpRateLimiterKeyResolver.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/DefaultRateLimiterKeyResolver.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ExpressionRateLimiterKeyResolver.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ServerNodeRateLimiterKeyResolver.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/UserRateLimiterKeyResolver.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/redis/RateLimiterRedisDAO.java create mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/package-info.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/package-info.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/ã€ŠèŠ‹é“ Spring Boot æœåŠ¡å®¹é”™ Resilience4j 入门》.md diff --git a/README.md b/README.md index c0d66ac38..1f40520b1 100644 --- a/README.md +++ b/README.md @@ -190,9 +190,7 @@ | 🚀 | Java 监控 | 基于 Spring Boot Admin 实现 Java 应用的监控 | | 🚀 | 链路追踪 | 接入 SkyWalking 组件,实现链路追踪 | | 🚀 | 日志中心 | 接入 SkyWalking 组件,实现日志中心 | -| 🚀 | 分布å¼é” | 基于 Redis 实现分布å¼é”,满足并å‘场景 | -| 🚀 | 幂等组件 | 基于 Redis 实现幂等组件,解决é‡å¤è¯·æ±‚问题 | -| 🚀 | æœåŠ¡ä¿éšœ | 基于 Resilience4j 实现æœåŠ¡çš„稳定性,包括é™æµã€ç†”断等功能 | +| 🚀 | æœåŠ¡ä¿éšœ | 基于 Redis 实现分布å¼é”ã€å¹‚ç­‰ã€é™æµåŠŸèƒ½ï¼Œæ»¡è¶³é«˜å¹¶å‘场景 | | 🚀 | 日志æœåŠ¡ | è½»é‡çº§æ—¥å¿—中心,查看远程æœåŠ¡å™¨çš„日志 | | 🚀 | å•å…ƒæµ‹è¯• | 基于 JUnit + Mockito 实现å•å…ƒæµ‹è¯•ï¼Œä¿è¯åŠŸèƒ½çš„正确性ã€ä»£ç çš„è´¨é‡ç­‰ | diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 694cf7492..7d2db639c 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -40,7 +40,6 @@ 2.4.0 2.2.7 - 2.1.0 9.0.0 3.2.1 @@ -319,17 +318,6 @@ - - io.github.resilience4j - resilience4j-ratelimiter - ${resilience4j.version} - - - io.github.resilience4j - resilience4j-spring-boot3 - ${resilience4j.version} - - cn.iocoder.cloud diff --git a/yudao-framework/yudao-spring-boot-starter-protection/pom.xml b/yudao-framework/yudao-spring-boot-starter-protection/pom.xml index f230da261..da4570b94 100644 --- a/yudao-framework/yudao-spring-boot-starter-protection/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-protection/pom.xml @@ -16,6 +16,13 @@ https://github.com/YunaiV/ruoyi-vue-pro + + + cn.iocoder.cloud + yudao-spring-boot-starter-web + provided + + cn.iocoder.cloud @@ -28,12 +35,6 @@ lock4j-redisson-spring-boot-starter true - - - io.github.resilience4j - resilience4j-spring-boot2 - true - diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/idempotent/core/aop/IdempotentAspect.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/idempotent/core/aop/IdempotentAspect.java index 2d8c76d55..11ff76576 100644 --- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/idempotent/core/aop/IdempotentAspect.java +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/idempotent/core/aop/IdempotentAspect.java @@ -37,7 +37,7 @@ public class IdempotentAspect { } @Around(value = "@annotation(idempotent)") - public Object beforePointCut(ProceedingJoinPoint joinPoint, Idempotent idempotent) throws Throwable { + public Object aroundPointCut(ProceedingJoinPoint joinPoint, Idempotent idempotent) throws Throwable { // 获得 IdempotentKeyResolver IdempotentKeyResolver keyResolver = keyResolvers.get(idempotent.keyResolver()); Assert.notNull(keyResolver, "找ä¸åˆ°å¯¹åº”çš„ IdempotentKeyResolver"); @@ -48,7 +48,7 @@ public class IdempotentAspect { boolean success = idempotentRedisDAO.setIfAbsent(key, idempotent.timeout(), idempotent.timeUnit()); // é”定失败,抛出异常 if (!success) { - log.info("[beforePointCut][方法({}) å‚æ•°({}) 存在é‡å¤è¯·æ±‚]", joinPoint.getSignature().toString(), joinPoint.getArgs()); + log.info("[aroundPointCut][方法({}) å‚æ•°({}) 存在é‡å¤è¯·æ±‚]", joinPoint.getSignature().toString(), joinPoint.getArgs()); throw new ServiceException(GlobalErrorCodeConstants.REPEATED_REQUESTS.getCode(), idempotent.message()); } diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/config/YudaoRateLimiterConfiguration.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/config/YudaoRateLimiterConfiguration.java new file mode 100644 index 000000000..68b910fea --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/config/YudaoRateLimiterConfiguration.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.framework.ratelimiter.config; + +import cn.iocoder.yudao.framework.ratelimiter.core.aop.RateLimiterAspect; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl.*; +import cn.iocoder.yudao.framework.ratelimiter.core.redis.RateLimiterRedisDAO; +import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; +import org.redisson.api.RedissonClient; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.Bean; + +import java.util.List; + +@AutoConfiguration(after = YudaoRedisAutoConfiguration.class) +public class YudaoRateLimiterConfiguration { + + @Bean + public RateLimiterAspect rateLimiterAspect(List keyResolvers, RateLimiterRedisDAO rateLimiterRedisDAO) { + return new RateLimiterAspect(keyResolvers, rateLimiterRedisDAO); + } + + @Bean + @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") + public RateLimiterRedisDAO rateLimiterRedisDAO(RedissonClient redissonClient) { + return new RateLimiterRedisDAO(redissonClient); + } + + // ========== å„ç§ RateLimiterRedisDAO Bean ========== + + @Bean + public DefaultRateLimiterKeyResolver defaultRateLimiterKeyResolver() { + return new DefaultRateLimiterKeyResolver(); + } + + @Bean + public UserRateLimiterKeyResolver userRateLimiterKeyResolver() { + return new UserRateLimiterKeyResolver(); + } + + @Bean + public ClientIpRateLimiterKeyResolver clientIpRateLimiterKeyResolver() { + return new ClientIpRateLimiterKeyResolver(); + } + + @Bean + public ServerNodeRateLimiterKeyResolver serverNodeRateLimiterKeyResolver() { + return new ServerNodeRateLimiterKeyResolver(); + } + + @Bean + public ExpressionRateLimiterKeyResolver expressionRateLimiterKeyResolver() { + return new ExpressionRateLimiterKeyResolver(); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/annotation/RateLimiter.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/annotation/RateLimiter.java new file mode 100644 index 000000000..417c4d642 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/annotation/RateLimiter.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.annotation; + +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.iocoder.yudao.framework.idempotent.core.keyresolver.impl.ExpressionIdempotentKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl.ClientIpRateLimiterKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl.DefaultRateLimiterKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl.ServerNodeRateLimiterKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl.UserRateLimiterKeyResolver; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.concurrent.TimeUnit; + +/** + * é™æµæ³¨è§£ + * + * @author 芋é“æºç  + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface RateLimiter { + + /** + * é™æµçš„时间,默认为 1 秒 + */ + int time() default 1; + /** + * 时间å•ä½ï¼Œé»˜è®¤ä¸º SECONDS 秒 + */ + TimeUnit timeUnit() default TimeUnit.SECONDS; + + /** + * é™æµæ¬¡æ•° + */ + int count() default 100; + + /** + * æ示信æ¯ï¼Œè¯·æ±‚过快的æ示 + * + * @see GlobalErrorCodeConstants#TOO_MANY_REQUESTS + */ + String message() default ""; // 为空时,使用 TOO_MANY_REQUESTS 错误æ示 + + /** + * 使用的 Key 解æžå™¨ + * + * @see DefaultRateLimiterKeyResolver 全局级别 + * @see UserRateLimiterKeyResolver 用户 ID 级别 + * @see ClientIpRateLimiterKeyResolver 用户 IP 级别 + * @see ServerNodeRateLimiterKeyResolver æœåŠ¡å™¨ Node 级别 + * @see ExpressionIdempotentKeyResolver 自定义表达å¼ï¼Œé€šè¿‡ {@link #keyArg()} 计算 + */ + Class keyResolver() default DefaultRateLimiterKeyResolver.class; + /** + * 使用的 Key å‚æ•° + */ + String keyArg() default ""; + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/aop/RateLimiterAspect.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/aop/RateLimiterAspect.java new file mode 100644 index 000000000..6ede62bea --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/aop/RateLimiterAspect.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.aop; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.exception.ServiceException; +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import cn.iocoder.yudao.framework.ratelimiter.core.redis.RateLimiterRedisDAO; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.Map; + +/** + * 拦截声明了 {@link RateLimiter} 注解的方法,实现é™æµæ“作 + * + * @author 芋é“æºç  + */ +@Aspect +@Slf4j +public class RateLimiterAspect { + + /** + * RateLimiterKeyResolver é›†åˆ + */ + private final Map, RateLimiterKeyResolver> keyResolvers; + + private final RateLimiterRedisDAO rateLimiterRedisDAO; + + public RateLimiterAspect(List keyResolvers, RateLimiterRedisDAO rateLimiterRedisDAO) { + this.keyResolvers = CollectionUtils.convertMap(keyResolvers, RateLimiterKeyResolver::getClass); + this.rateLimiterRedisDAO = rateLimiterRedisDAO; + } + + @Before("@annotation(rateLimiter)") + public void beforePointCut(JoinPoint joinPoint, RateLimiter rateLimiter) { + // 获得 IdempotentKeyResolver 对象 + RateLimiterKeyResolver keyResolver = keyResolvers.get(rateLimiter.keyResolver()); + Assert.notNull(keyResolver, "找ä¸åˆ°å¯¹åº”çš„ RateLimiterKeyResolver"); + // è§£æž Key + String key = keyResolver.resolver(joinPoint, rateLimiter); + + // èŽ·å– 1 次é™æµ + boolean success = rateLimiterRedisDAO.tryAcquire(key, + rateLimiter.count(), rateLimiter.time(), rateLimiter.timeUnit()); + if (!success) { + log.info("[beforePointCut][方法({}) å‚æ•°({}) 请求过于频ç¹]", joinPoint.getSignature().toString(), joinPoint.getArgs()); + String message = StrUtil.blankToDefault(rateLimiter.message(), + GlobalErrorCodeConstants.TOO_MANY_REQUESTS.getMsg()); + throw new ServiceException(GlobalErrorCodeConstants.TOO_MANY_REQUESTS.getCode(), message); + } + } + +} + diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/RateLimiterKeyResolver.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/RateLimiterKeyResolver.java new file mode 100644 index 000000000..44d7bdff5 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/RateLimiterKeyResolver.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.keyresolver; + +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import org.aspectj.lang.JoinPoint; + +/** + * é™æµ Key 解æžå™¨æŽ¥å£ + * + * @author 芋é“æºç  + */ +public interface RateLimiterKeyResolver { + + /** + * 解æžä¸€ä¸ª Key + * + * @param rateLimiter é™æµæ³¨è§£ + * @param joinPoint AOP åˆ‡é¢ + * @return Key + */ + String resolver(JoinPoint joinPoint, RateLimiter rateLimiter); + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ClientIpRateLimiterKeyResolver.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ClientIpRateLimiterKeyResolver.java new file mode 100644 index 000000000..8d6253caa --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ClientIpRateLimiterKeyResolver.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import org.aspectj.lang.JoinPoint; + +/** + * IP 级别的é™æµ Key 解æžå™¨ï¼Œä½¿ç”¨æ–¹æ³•å + 方法å‚æ•° + IP,组装æˆä¸€ä¸ª Key + * + * 为了é¿å… Key 过长,使用 MD5 进行“压缩†+ * + * @author 芋é“æºç  + */ +public class ClientIpRateLimiterKeyResolver implements RateLimiterKeyResolver { + + @Override + public String resolver(JoinPoint joinPoint, RateLimiter rateLimiter) { + String methodName = joinPoint.getSignature().toString(); + String argsStr = StrUtil.join(",", joinPoint.getArgs()); + String clientIp = ServletUtils.getClientIP(); + return SecureUtil.md5(methodName + argsStr + clientIp); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/DefaultRateLimiterKeyResolver.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/DefaultRateLimiterKeyResolver.java new file mode 100644 index 000000000..236ea45cb --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/DefaultRateLimiterKeyResolver.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import org.aspectj.lang.JoinPoint; + +/** + * 默认(全局级别)é™æµ Key 解æžå™¨ï¼Œä½¿ç”¨æ–¹æ³•å + 方法å‚数,组装æˆä¸€ä¸ª Key + * + * 为了é¿å… Key 过长,使用 MD5 进行“压缩†+ * + * @author 芋é“æºç  + */ +public class DefaultRateLimiterKeyResolver implements RateLimiterKeyResolver { + + @Override + public String resolver(JoinPoint joinPoint, RateLimiter rateLimiter) { + String methodName = joinPoint.getSignature().toString(); + String argsStr = StrUtil.join(",", joinPoint.getArgs()); + return SecureUtil.md5(methodName + argsStr); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ExpressionRateLimiterKeyResolver.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ExpressionRateLimiterKeyResolver.java new file mode 100644 index 000000000..118581e35 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ExpressionRateLimiterKeyResolver.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl; + +import cn.hutool.core.util.ArrayUtil; +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.core.DefaultParameterNameDiscoverer; +import org.springframework.core.ParameterNameDiscoverer; +import org.springframework.expression.Expression; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; + +import java.lang.reflect.Method; + +/** + * 基于 Spring EL 表达å¼çš„ {@link RateLimiterKeyResolver} 实现类 + * + * @author 芋é“æºç  + */ +public class ExpressionRateLimiterKeyResolver implements RateLimiterKeyResolver { + + private final ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer(); + + private final ExpressionParser expressionParser = new SpelExpressionParser(); + + @Override + public String resolver(JoinPoint joinPoint, RateLimiter rateLimiter) { + // 获得被拦截方法å‚æ•°å列表 + Method method = getMethod(joinPoint); + Object[] args = joinPoint.getArgs(); + String[] parameterNames = this.parameterNameDiscoverer.getParameterNames(method); + // 准备 Spring EL 表达å¼è§£æžçš„上下文 + StandardEvaluationContext evaluationContext = new StandardEvaluationContext(); + if (ArrayUtil.isNotEmpty(parameterNames)) { + for (int i = 0; i < parameterNames.length; i++) { + evaluationContext.setVariable(parameterNames[i], args[i]); + } + } + + // 解æžå‚æ•° + Expression expression = expressionParser.parseExpression(rateLimiter.keyArg()); + return expression.getValue(evaluationContext, String.class); + } + + private static Method getMethod(JoinPoint point) { + // 处ç†ï¼Œå£°æ˜Žåœ¨ç±»ä¸Šçš„情况 + MethodSignature signature = (MethodSignature) point.getSignature(); + Method method = signature.getMethod(); + if (!method.getDeclaringClass().isInterface()) { + return method; + } + + // 处ç†ï¼Œå£°æ˜Žåœ¨æŽ¥å£ä¸Šçš„情况 + try { + return point.getTarget().getClass().getDeclaredMethod( + point.getSignature().getName(), method.getParameterTypes()); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ServerNodeRateLimiterKeyResolver.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ServerNodeRateLimiterKeyResolver.java new file mode 100644 index 000000000..300a4d2f1 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/ServerNodeRateLimiterKeyResolver.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.system.SystemUtil; +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import org.aspectj.lang.JoinPoint; + +/** + * Server 节点级别的é™æµ Key 解æžå™¨ï¼Œä½¿ç”¨æ–¹æ³•å + 方法å‚æ•° + IP,组装æˆä¸€ä¸ª Key + * + * 为了é¿å… Key 过长,使用 MD5 进行“压缩†+ * + * @author 芋é“æºç  + */ +public class ServerNodeRateLimiterKeyResolver implements RateLimiterKeyResolver { + + @Override + public String resolver(JoinPoint joinPoint, RateLimiter rateLimiter) { + String methodName = joinPoint.getSignature().toString(); + String argsStr = StrUtil.join(",", joinPoint.getArgs()); + String serverNode = String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID()); + return SecureUtil.md5(methodName + argsStr + serverNode); + } + +} \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/UserRateLimiterKeyResolver.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/UserRateLimiterKeyResolver.java new file mode 100644 index 000000000..a8d1c3a98 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/keyresolver/impl/UserRateLimiterKeyResolver.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter; +import cn.iocoder.yudao.framework.ratelimiter.core.keyresolver.RateLimiterKeyResolver; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; +import org.aspectj.lang.JoinPoint; + +/** + * 用户级别的é™æµ Key 解æžå™¨ï¼Œä½¿ç”¨æ–¹æ³•å + 方法å‚æ•° + userId + userType,组装æˆä¸€ä¸ª Key + * + * 为了é¿å… Key 过长,使用 MD5 进行“压缩†+ * + * @author 芋é“æºç  + */ +public class UserRateLimiterKeyResolver implements RateLimiterKeyResolver { + + @Override + public String resolver(JoinPoint joinPoint, RateLimiter rateLimiter) { + String methodName = joinPoint.getSignature().toString(); + String argsStr = StrUtil.join(",", joinPoint.getArgs()); + Long userId = WebFrameworkUtils.getLoginUserId(); + Integer userType = WebFrameworkUtils.getLoginUserType(); + return SecureUtil.md5(methodName + argsStr + userId + userType); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/redis/RateLimiterRedisDAO.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/redis/RateLimiterRedisDAO.java new file mode 100644 index 000000000..fc1378f3b --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/core/redis/RateLimiterRedisDAO.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.framework.ratelimiter.core.redis; + +import lombok.AllArgsConstructor; +import org.redisson.api.*; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +/** + * é™æµ Redis DAO + * + * @author 芋é“æºç  + */ +@AllArgsConstructor +public class RateLimiterRedisDAO { + + /** + * é™æµæ“作 + * + * KEY æ ¼å¼ï¼šrate_limiter:%s // å‚数为 uuid + * VALUE æ ¼å¼ï¼šString + * 过期时间:ä¸å›ºå®š + */ + private static final String RATE_LIMITER = "rate_limiter:%s"; + + private final RedissonClient redissonClient; + + public Boolean tryAcquire(String key, int count, int time, TimeUnit timeUnit) { + // 1. 获得 RRateLimiter,并设置 rate 速率 + RRateLimiter rateLimiter = getRRateLimiter(key, count, time, timeUnit); + // 2. å°è¯•èŽ·å– 1 个 + return rateLimiter.tryAcquire(); + } + + private static String formatKey(String key) { + return String.format(RATE_LIMITER, key); + } + + private RRateLimiter getRRateLimiter(String key, long count, int time, TimeUnit timeUnit) { + String redisKey = formatKey(key); + RRateLimiter rateLimiter = redissonClient.getRateLimiter(redisKey); + long rateInterval = timeUnit.toSeconds(time); + // 1. 如果ä¸å­˜åœ¨ï¼Œè®¾ç½® rate 速率 + RateLimiterConfig config = rateLimiter.getConfig(); + if (config == null) { + rateLimiter.trySetRate(RateType.OVERALL, count, rateInterval, RateIntervalUnit.SECONDS); + return rateLimiter; + } + // 2. 如果存在,并且é…置相åŒï¼Œåˆ™ç›´æŽ¥è¿”回 + if (config.getRateType() == RateType.OVERALL + && Objects.equals(config.getRate(), count) + && Objects.equals(config.getRateInterval(), TimeUnit.SECONDS.toMillis(rateInterval))) { + return rateLimiter; + } + // 3. 如果存在,并且é…ç½®ä¸åŒï¼Œåˆ™è¿›è¡Œæ–°å»º + rateLimiter.setRate(RateType.OVERALL, count, rateInterval, RateIntervalUnit.SECONDS); + return rateLimiter; + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/package-info.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/package-info.java new file mode 100644 index 000000000..36a408c8e --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/ratelimiter/package-info.java @@ -0,0 +1,4 @@ +/** + * é™æµç»„件,基于 Redisson {@link org.redisson.api.RRateLimiter} é™æµå®žçŽ° + */ +package cn.iocoder.yudao.framework.ratelimiter; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/package-info.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/package-info.java deleted file mode 100644 index 649e8a0ea..000000000 --- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 使用 Resilience4j 组件,实现æœåŠ¡ä¿éšœï¼ŒåŒ…括: - * 1. 熔断器 - * 2. é™æµå™¨ - * 3. 舱å£éš”离 - * 4. é‡è¯• - * 5. é™æ—¶å™¨ - */ -package cn.iocoder.yudao.framework.resilience4j; diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/ã€ŠèŠ‹é“ Spring Boot æœåŠ¡å®¹é”™ Resilience4j 入门》.md b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/ã€ŠèŠ‹é“ Spring Boot æœåŠ¡å®¹é”™ Resilience4j 入门》.md deleted file mode 100644 index 8d6d0335b..000000000 --- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/resilience4j/ã€ŠèŠ‹é“ Spring Boot æœåŠ¡å®¹é”™ Resilience4j 入门》.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-framework/yudao-spring-boot-starter-protection/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 563a5316f..d7cd3a883 100644 --- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,2 +1,3 @@ cn.iocoder.yudao.framework.idempotent.config.YudaoIdempotentConfiguration cn.iocoder.yudao.framework.lock4j.config.YudaoLock4jConfiguration +cn.iocoder.yudao.framework.ratelimiter.config.YudaoRateLimiterConfiguration \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java index bd005d2d5..46aa1eb4b 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java @@ -4,14 +4,18 @@ import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.servlet.JakartaServletUtil; +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; -import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import jakarta.validation.ValidationException; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.AccessDeniedException; @@ -26,13 +30,8 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import org.springframework.web.servlet.NoHandlerFoundException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.ConstraintViolation; -import jakarta.validation.ConstraintViolationException; -import jakarta.validation.ValidationException; import java.time.LocalDateTime; import java.util.Map; -import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.*; @@ -181,14 +180,6 @@ public class GlobalExceptionHandler { return CommonResult.error(METHOD_NOT_ALLOWED.getCode(), String.format("请求方法ä¸æ­£ç¡®:%s", ex.getMessage())); } - /** - * å¤„ç† Resilience4j é™æµæŠ›å‡ºçš„异常 - */ - public CommonResult requestNotPermittedExceptionHandler(HttpServletRequest req, Throwable ex) { - log.warn("[requestNotPermittedExceptionHandler][url({}) 访问过于频ç¹]", req.getRequestURL(), ex); - return CommonResult.error(TOO_MANY_REQUESTS); - } - /** * å¤„ç† Spring Security æƒé™ä¸è¶³çš„异常 * @@ -223,12 +214,7 @@ public class GlobalExceptionHandler { return tableNotExistsResult; } - // æƒ…å†µäºŒï¼šéƒ¨åˆ†ç‰¹æ®Šçš„åº“çš„å¤„ç† - if (Objects.equals("io.github.resilience4j.ratelimiter.RequestNotPermitted", ex.getClass().getName())) { - return requestNotPermittedExceptionHandler(req, ex); - } - - // 情况三:处ç†å¼‚常 + // 情况二:处ç†å¼‚常 log.error("[defaultExceptionHandler]", ex); // æ’入异常日志 createExceptionLog(req, ex); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml index 7c044484a..9d37b82c2 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml @@ -35,8 +35,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml index 0f28838da..a55b301c6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml @@ -39,8 +39,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml index ef6c5a14b..f9b5f3291 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml @@ -42,8 +42,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml index 42b71c3a8..74906627e 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml @@ -39,8 +39,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml index 9be292ba2..c1f65733a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml @@ -38,8 +38,6 @@ mybatis: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml index 0bf3bec33..ab50eb591 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml @@ -38,8 +38,6 @@ mybatis: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml b/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml index 9be292ba2..c1f65733a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml @@ -38,8 +38,6 @@ mybatis: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml index fa369b9d5..15fa79bd5 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml +++ b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml @@ -70,16 +70,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 -resilience4j: - ratelimiter: - instances: - backendA: - limit-for-period: 1 # æ¯ä¸ªå‘¨æœŸå†…,å…许的请求数。默认为 50 - limit-refresh-period: 60s # æ¯ä¸ªå‘¨æœŸçš„时长,å•ä½ï¼šå¾®ç§’。默认为 500 - timeout-duration: 1s # 被é™æµæ—¶ï¼Œé˜»å¡žç­‰å¾…的时长,å•ä½ï¼šå¾®ç§’。默认为 5s - register-health-indicator: true # 是å¦æ³¨å†Œåˆ°å¥åº·ç›‘测 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml index 167dc9bc5..93023bdfb 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml @@ -43,8 +43,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml b/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml index 1616c4de6..192afd268 100644 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml @@ -42,8 +42,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml b/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml index e5d653d6e..9ede62572 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml @@ -74,16 +74,6 @@ mybatis: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 -resilience4j: - ratelimiter: - instances: - backendA: - limit-for-period: 1 # æ¯ä¸ªå‘¨æœŸå†…,å…许的请求数。默认为 50 - limit-refresh-period: 60s # æ¯ä¸ªå‘¨æœŸçš„时长,å•ä½ï¼šå¾®ç§’。默认为 500 - timeout-duration: 1s # 被é™æµæ—¶ï¼Œé˜»å¡žç­‰å¾…的时长,å•ä½ï¼šå¾®ç§’。默认为 5s - register-health-indicator: true # 是å¦æ³¨å†Œåˆ°å¥åº·ç›‘测 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® #################### diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml b/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml index f2b0d6517..432c1e395 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml @@ -43,8 +43,6 @@ mybatis-plus: # Lock4j é…置项(å•å…ƒæµ‹è¯•ï¼Œç¦ç”¨ Lock4j) -# Resilience4j é…置项 - --- #################### 监控相关é…ç½® #################### --- #################### 芋é“相关é…ç½® ####################