Class FeignDecorators.Builder

java.lang.Object
io.github.resilience4j.feign.FeignDecorators.Builder
Enclosing class:
FeignDecorators

public static final class FeignDecorators.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • withRetry

      public FeignDecorators.Builder withRetry(io.github.resilience4j.retry.Retry retry)
      Adds a Retry to the decorator chain.
      Parameters:
      retry - a fully configured Retry.
      Returns:
      the builder
    • withCircuitBreaker

      public FeignDecorators.Builder withCircuitBreaker(io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker)
      Adds a CircuitBreaker to the decorator chain.
      Parameters:
      circuitBreaker - a fully configured CircuitBreaker.
      Returns:
      the builder
    • withRateLimiter

      public FeignDecorators.Builder withRateLimiter(io.github.resilience4j.ratelimiter.RateLimiter rateLimiter)
      Adds a RateLimiter to the decorator chain.
      Parameters:
      rateLimiter - a fully configured RateLimiter.
      Returns:
      the builder
    • withFallback

      public FeignDecorators.Builder withFallback(Object fallback)
      Adds a fallback to the decorator chain. Multiple fallbacks can be applied with the next fallback being called when the previous one fails.
      Parameters:
      fallback - must match the feign interface, i.e. the interface specified when calling Feign.Builder.target(Class, String).
      Returns:
      the builder
    • withFallbackFactory

      public FeignDecorators.Builder withFallbackFactory(Function<Exception,?> fallbackFactory)
      Adds a fallback factory to the decorator chain. A factory can consume the exception thrown on error. Multiple fallbacks can be applied with the next fallback being called when the previous one fails.
      Parameters:
      fallbackFactory - must match the feign interface, i.e. the interface specified when calling Feign.Builder.target(Class, String).
      Returns:
      the builder
    • withFallback

      public FeignDecorators.Builder withFallback(Object fallback, Class<? extends Exception> filter)
      Adds a fallback to the decorator chain. Multiple fallbacks can be applied with the next fallback being called when the previous one fails.
      Parameters:
      fallback - must match the feign interface, i.e. the interface specified when calling Feign.Builder.target(Class, String).
      filter - only Exceptions matching the specified Exception will trigger the fallback.
      Returns:
      the builder
    • withFallbackFactory

      public FeignDecorators.Builder withFallbackFactory(Function<Exception,?> fallbackFactory, Class<? extends Exception> filter)
      Adds a fallback factory to the decorator chain. A factory can consume the exception thrown on error. Multiple fallbacks can be applied with the next fallback being called when the previous one fails.
      Parameters:
      fallbackFactory - must match the feign interface, i.e. the interface specified when calling Feign.Builder.target(Class, String).
      filter - only Exceptions matching the specified Exception will trigger the fallback.
      Returns:
      the builder
    • withFallback

      public FeignDecorators.Builder withFallback(Object fallback, Predicate<Exception> filter)
      Adds a fallback to the decorator chain. Multiple fallbacks can be applied with the next fallback being called when the previous one fails.
      Parameters:
      fallback - must match the feign interface, i.e. the interface specified when calling Feign.Builder.target(Class, String).
      filter - the filter must return true for the fallback to be called.
      Returns:
      the builder
    • withFallbackFactory

      public FeignDecorators.Builder withFallbackFactory(Function<Exception,?> fallbackFactory, Predicate<Exception> filter)
      Adds a fallback to the decorator chain. A factory can consume the exception thrown on error. Multiple fallbacks can be applied with the next fallback being called when the previous one fails.
      Parameters:
      fallbackFactory - must match the feign interface, i.e. the interface specified when calling Feign.Builder.target(Class, String).
      filter - the filter must return true for the fallback to be called.
      Returns:
      the builder
    • withBulkhead

      public FeignDecorators.Builder withBulkhead(io.github.resilience4j.bulkhead.Bulkhead bulkhead)
      Adds a Bulkhead to the decorator chain.
      Parameters:
      bulkhead - a fully configured Bulkhead.
      Returns:
      the builder
    • build

      public FeignDecorators build()
      Builds the decorator chain. This can then be used to setup an instance of Resilience4jFeign.
      Returns:
      the decorators.