Class RateLimiterAspect
java.lang.Object
io.github.resilience4j.ratelimiter.configure.RateLimiterAspect
- All Implemented Interfaces:
org.springframework.core.Ordered
This Spring AOP aspect intercepts all methods which are annotated with a
RateLimiter
annotation. The aspect will handle methods that return a RxJava2 reactive type, Spring Reactor
reactive type, CompletionStage type, or value type.
The RateLimiterRegistry is used to retrieve an instance of a RateLimiter for a specific backend.
Given a method like this:
@RateLimiter(name = "myService")
public String fancyName(String name) {
return "Sir Captain " + name;
}
each time the #fancyName(String)
method is invoked, the method's execution will pass
through a a RateLimiter
according to the given
config.
The fallbackMethod parameter signature must match either:
1) The method parameter signature on the annotated method or 2) The method parameter signature with a matching exception type as the last parameter on the annotated method
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorsConstructorDescriptionRateLimiterAspect
(io.github.resilience4j.ratelimiter.RateLimiterRegistry rateLimiterRegistry, RateLimiterConfigurationProperties properties, List<RateLimiterAspectExt> rateLimiterAspectExtList, FallbackExecutor fallbackExecutor, SpelResolver spelResolver) -
Method Summary
Modifier and TypeMethodDescriptionint
getOrder()
void
matchAnnotatedClassOrMethod
(io.github.resilience4j.ratelimiter.annotation.RateLimiter rateLimiter) Method used as pointcutrateLimiterAroundAdvice
(org.aspectj.lang.ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.ratelimiter.annotation.RateLimiter rateLimiterAnnotation)
-
Constructor Details
-
RateLimiterAspect
public RateLimiterAspect(io.github.resilience4j.ratelimiter.RateLimiterRegistry rateLimiterRegistry, RateLimiterConfigurationProperties properties, @Autowired(required=false) List<RateLimiterAspectExt> rateLimiterAspectExtList, FallbackExecutor fallbackExecutor, SpelResolver spelResolver)
-
-
Method Details
-
matchAnnotatedClassOrMethod
public void matchAnnotatedClassOrMethod(io.github.resilience4j.ratelimiter.annotation.RateLimiter rateLimiter) Method used as pointcut- Parameters:
rateLimiter
- - matched annotation
-
rateLimiterAroundAdvice
public Object rateLimiterAroundAdvice(org.aspectj.lang.ProceedingJoinPoint proceedingJoinPoint, @Nullable io.github.resilience4j.ratelimiter.annotation.RateLimiter rateLimiterAnnotation) throws Throwable - Throws:
Throwable
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-