Package io.github.resilience4j.feign
Class FeignDecorators
- java.lang.Object
-
- io.github.resilience4j.feign.FeignDecorators
-
- All Implemented Interfaces:
FeignDecorator
public class FeignDecorators extends java.lang.Object implements FeignDecorator
Builder to help build stacked decorators.
{ @code CircuitBreaker circuitBreaker = CircuitBreaker.ofDefaults("backendName"); RateLimiter rateLimiter = RateLimiter.ofDefaults("backendName"); FeignDecorators decorators = FeignDecorators.builder() .withCircuitBreaker(circuitBreaker) .withRateLimiter(rateLimiter) .build(); MyService myService = Resilience4jFeign.builder(decorators).target(MyService.class, "http://localhost:8080/"); }The order in which decorators are applied correspond to the order in which they are declared. For example, calling
FeignDecorators.Builder.withFallback(Object)beforeFeignDecorators.Builder.withCircuitBreaker(CircuitBreaker)would mean that the fallback is called when the HTTP request fails, but would no longer be reachable if the CircuitBreaker were open. However, reversing the order would mean that the fallback is called both when the HTTP request fails and when the CircuitBreaker is open.
So be wary of this when designing your "resilience" strategy.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFeignDecorators.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FeignDecorators.Builderbuilder()io.vavr.CheckedFunction1<java.lang.Object[],java.lang.Object>decorate(io.vavr.CheckedFunction1<java.lang.Object[],java.lang.Object> fn, java.lang.reflect.Method method, feign.InvocationHandlerFactory.MethodHandler methodHandler, feign.Target<?> target)Decorates the invocation of a method defined by a feign interface.
-
-
-
Method Detail
-
builder
public static FeignDecorators.Builder builder()
-
decorate
public io.vavr.CheckedFunction1<java.lang.Object[],java.lang.Object> decorate(io.vavr.CheckedFunction1<java.lang.Object[],java.lang.Object> fn, java.lang.reflect.Method method, feign.InvocationHandlerFactory.MethodHandler methodHandler, feign.Target<?> target)Description copied from interface:FeignDecoratorDecorates the invocation of a method defined by a feign interface.- Specified by:
decoratein interfaceFeignDecorator- Parameters:
fn- represents the call to the method. This should be decorated by the implementing class.method- the method of the feign interface that is invoked.methodHandler- the feign methodHandler that executes the http request.- Returns:
- the decorated invocationCall
-
-