Class Retryer.ForReturnValue<T>

java.lang.Object
com.google.mu.util.concurrent.Retryer.ForReturnValue<T>
Enclosing class:
Retryer

public static final class Retryer.ForReturnValue<T> extends Object
Retries based on return values.
  • Method Details

    • retryBlockingly

      public <R extends T, E extends Throwable> R retryBlockingly(CheckedSupplier<R,E> supplier) throws E
      Invokes and possibly retries supplier according to the retry strategies specified with uponReturn().

      This method blocks while waiting to retry. If interrupted, retry is canceled.

      If supplier fails despite retrying, the return value from the most recent invocation is returned.

      Throws:
      E
    • retry

      public <R extends T, E extends Throwable> CompletionStage<R> retry(CheckedSupplier<? extends R,E> supplier, ScheduledExecutorService retryExecutor)
      Invokes and possibly retries supplier according to the retry strategies specified with uponReturn().

      The first invocation is done in the current thread. Unchecked exceptions thrown by supplier directly are propagated. This is to avoid hiding programming errors. Checked exceptions are reported through the returned CompletionStage so callers only need to deal with them in one place.

      Retries are scheduled and performed by executor.

      Canceling the returned future object will cancel currently pending retry attempts. Same if supplier throws InterruptedException.

      NOTE that if executor.shutdownNow() is called, the returned CompletionStage will never be done.

    • retryAsync

      public <R extends T, E extends Throwable> CompletionStage<R> retryAsync(CheckedSupplier<? extends CompletionStage<R>,E> asyncSupplier, ScheduledExecutorService retryExecutor)
      Invokes and possibly retries asyncSupplier according to the retry strategies specified with uponReturn().

      The first invocation is done in the current thread. Unchecked exceptions thrown by asyncSupplier directly are propagated. This is to avoid hiding programming errors. Checked exceptions are reported through the returned CompletionStage so callers only need to deal with them in one place.

      Retries are scheduled and performed by executor.

      Canceling the returned future object will cancel currently pending retry attempts. Same if supplier throws InterruptedException.

      NOTE that if executor.shutdownNow() is called, the returned CompletionStage will never be done.