Class FaultTolerance

java.lang.Object
io.helidon.faulttolerance.FaultTolerance

public final class FaultTolerance extends Object
System-wide fault tolerance configuration and access to a customized sequence of fault tolerance handlers.

Fault tolerance provides the following features:

  • Bulkhead - limit number of parallel requests to a resource
  • CircuitBreaker - stop trying to request a failing resource until it becomes available
  • Fallback - fall back to another supplier of result in case the usual one fails
  • Retry - try to call a supplier again if invocation fails
  • Timeout - time out a request if it takes too long
See Also:
  • Method Details

    • config

      public static void config(Config config)
      Configure Helidon wide defaults from a config instance.
      Parameters:
      config - config to read fault tolerance configuration
    • executor

      public static void executor(Supplier<? extends ExecutorService> executor)
      Configure Helidon wide executor service for Fault Tolerance.
      Parameters:
      executor - executor service to use
    • builder

      public static FaultTolerance.Builder builder()
      A builder to configure a customized sequence of fault tolerance handlers.
      Returns:
      a new builder
    • typedBuilder

      public static <T> FaultTolerance.TypedBuilder<T> typedBuilder()
      A typed builder to configure a customized sequence of fault tolerance handlers.
      Type Parameters:
      T - type of result
      Returns:
      a new builder
    • toDelayedRunnable

      public static Runnable toDelayedRunnable(Runnable runnable, long millis)
      Converts a Runnable into another that sleeps for millis before executing. Simulates a scheduled executor when using VTs.
      Parameters:
      runnable - the runnable
      millis - the time to sleep
      Returns:
      the new runnable
    • toDelayedCallable

      public static <T> Callable<T> toDelayedCallable(Callable<T> callable, long millis)
      Converts a Callable into another that sleeps for millis before executing. Simulates a scheduled executor when using VTs.
      Type Parameters:
      T - type of value returned
      Parameters:
      callable - the callable
      millis - the time to sleep
      Returns:
      the new callable