面对使用Spring Cloud Redis RateLimiter将窗口周期更改为用户执行N请求的问题。问题是我可以设置用户每秒可以执行的N个请求,但是我需要将其更改为每分钟或2分钟N个请求。
可以通过某种方式做到吗?
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
var routeBuilder = routeLocatorBuilder.routes();
routeBuilder.route(route -> route.path("/some/service/path")
.filters(filterSpec -> filterSpec.requestRateLimiter(config -> config.setRateLimiter(new RedisRateLimiter(10, 20))
.setKeyResolver(new PrincipalNameKeyResolver()))
.stripPrefix(2))
.uri("http://specific-service/"));
return routeBuilder.build();
}