Class Retry.Builder

java.lang.Object
co.yellowdog.platform.clients.retry.Retry.Builder
Enclosing class:
Retry

public static class Retry.Builder extends Object
  • Constructor Details

    • Builder

      public Builder(Duration baseBackoffPeriod)
  • Method Details

    • maxBackoffPeriod

      public Retry.Builder maxBackoffPeriod(@NonNull @NonNull Duration maxBackoffPeriod)
      The maximum backoff period. By default, the backoff period will never stop increasing.
      Parameters:
      maxBackoffPeriod - the maximum backoff period.
      Returns:
      this builder.
    • maxAttempts

      public Retry.Builder maxAttempts(long maxAttempts)
      The maximum number of attempts to retry. By default, will retry indefinitely.

      An exception will be thrown if the maximum number of attempts is reached.

      Parameters:
      maxAttempts - the maximum number of attempts.
      Returns:
      this builder.
      Throws:
      IllegalArgumentException - if maxAttempts is less than 0.
    • retryOn

      public Retry.Builder retryOn(@NonNull @NonNull Predicate<Throwable> retryOnPredicate)
      The predicate to determine if a retry should be attempted. By default, will retry on any throwable.
      Parameters:
      retryOnPredicate - the predicate to determine if a retry should be attempted.
      Returns:
      this builder.
    • beforeRetry

      public Retry.Builder beforeRetry(@NonNull @NonNull RetryHandler retryHandler)
    • build

      public Retry build()