Interface Retryer


public interface Retryer
  • Method Details

    • get

      <T> T get(Callable<T> callable)
      Executes a Callable with the context of the retry. If the callable throws any exception, then the retryer will handle that according with the configuration the retryer was created.
      Type Parameters:
      T - type returned by provided Callable
      Parameters:
      callable - Callable to be executed
      Returns:
      the output from the callable
    • run

      void run(CheckedRunnable runnable)
      Executes a CheckedRunnable with the context of the retry. If the CheckedRunnable throws any exception, then the retryer will handle that according with the configuration the retryer was created.
      Parameters:
      runnable - CheckedRunnable to be executed
    • get

      <T> T get(Callable<T> callable, Consumer<SuccessfulAttempt> successfulAttemptConsumer, Consumer<FailedAttempt> failedAttemptConsumer)
      Executes a Callable with the context of the retry. If the callable throws any exception, then the retryer will handle that according with the configuration the retryer was created. This override provides consumer handlers that will allow you to create custom actions on each failure or successful attempt.
      Type Parameters:
      T - type returned by provided Callable
      Parameters:
      callable - Callable to be executed
      successfulAttemptConsumer - Consumer that accepts the SuccessfulAttempt, if there was one. This object contains context information such as "what retry did this succeed on?".
      failedAttemptConsumer - Consumer that accepts a FailedAttempt that provides retry context information such as error message.
      Returns:
      the output from the callable
    • run

      void run(CheckedRunnable runnable, Consumer<SuccessfulAttempt> successfulAttemptConsumer, Consumer<FailedAttempt> failedAttemptConsumer)
      Executes a CheckedRunnable with the context of the retry. If the CheckedRunnable throws any exception, then the retryer will handle that according with the configuration the retryer was created. This override provides consumer handlers that will allow you to create custom actions on each failure or successful attempt.
      Parameters:
      runnable - CheckedRunnable to be executed
      successfulAttemptConsumer - Consumer that accepts the SuccessfulAttempt, if there was one. This object contains context information such as "what retry did this succeed on?".
      failedAttemptConsumer - Consumer that accepts a FailedAttempt that provides retry context information such as error message.
    • withRetryOn

      Retryer withRetryOn(Predicate<Throwable> throwablePredicate)
      Optional predicates to be evaluated before the retryer implementation runs a retry
      Parameters:
      throwablePredicate - Predicate to verify against the exceptions thrown on the retry.
      Returns:
      current retryer, altered
    • withRetryIf

      <T> Retryer withRetryIf(Predicate<T> predicate)
      Optional predicates to be compared against the result of the "get" result of a retry. If it matches, will try again.
      Type Parameters:
      T - type accepted by predicate
      Parameters:
      predicate - Predicate to verify against the result of the retry.
      Returns:
      current retryer, altered