public class FeignDecorators extends java.lang.Object implements FeignDecorator
{
@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) before FeignDecorators.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.
| Modifier and Type | Class and Description |
|---|---|
static class |
FeignDecorators.Builder |
| Modifier and Type | Method and Description |
|---|---|
static FeignDecorators.Builder |
builder() |
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.
|
public static FeignDecorators.Builder builder()
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)
FeignDecoratordecorate in interface FeignDecoratorfn - 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.