Package feign.hystrix

Interface FallbackFactory<T>

  • Type Parameters:
    T - the feign interface type
    All Known Implementing Classes:
    FallbackFactory.Default

    public interface FallbackFactory<T>
    Used to control the fallback given its cause. Ex.
     
     // This instance will be invoked if there are errors of any kind.
     FallbackFactory<GitHub> fallbackFactory = cause -> (owner, repo) -> {
       if (cause instanceof FeignException && ((FeignException) cause).status() == 403) {
         return Collections.emptyList();
       } else {
         return Arrays.asList("yogi");
       }
     };
    
     GitHub github = HystrixFeign.builder()
                                 ...
                                 .target(GitHub.class, "https://api.github.com", fallbackFactory);
     
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  FallbackFactory.Default<T>
      Returns a constant fallback after logging the cause to FINE level.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T create​(java.lang.Throwable cause)
      Returns an instance of the fallback appropriate for the given cause
    • Method Detail

      • create

        T create​(java.lang.Throwable cause)
        Returns an instance of the fallback appropriate for the given cause
        Parameters:
        cause - corresponds to AbstractCommand.getExecutionException() often, but not always an instance of FeignException.