Class ResilienceConfiguration.RetryConfiguration

java.lang.Object
com.sap.cloud.sdk.cloudplatform.resilience.ResilienceConfiguration.RetryConfiguration
Enclosing class:
ResilienceConfiguration

public static final class ResilienceConfiguration.RetryConfiguration extends Object
Provides options specific to retries, which will reattempt failed requests a limited amount of times.
  • Field Details

    • DEFAULT_MAX_ATTEMPTS

      public static final int DEFAULT_MAX_ATTEMPTS
      The default number for maximum attempts.
      See Also:
    • DEFAULT_WAIT_DURATION

      public static final Duration DEFAULT_WAIT_DURATION
      The default waiting duration time.
    • DEFAULT_RETRY_ON_EXCEPTION_PREDICATE

      public static final Predicate<Throwable> DEFAULT_RETRY_ON_EXCEPTION_PREDICATE
      The default predicate for retrying if any exception occurs.
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Get the status indicator for the Retry.
      Returns:
      True if the configuration is enabled.
    • of

      @Nonnull public static ResilienceConfiguration.RetryConfiguration of(int maxAttempts, @Nonnull Duration waitDuration)
      Instantiate a new RetryConfiguration with the given parameters.
      Parameters:
      maxAttempts - The maximum number of attempts to successfully execute a request.
      waitDuration - The time duration the system will wait before retrying.
      Returns:
      An immutable RetryConfiguration.
    • of

      @Nonnull public static ResilienceConfiguration.RetryConfiguration of(int maxAttempts)
      Instantiate a new RetryConfiguration with the given parameter. Before retrying the system will wait for DEFAULT_WAIT_DURATION.
      Parameters:
      maxAttempts - The maximum number of attempts to successfully execute a request.
      Returns:
      An instance of RetryConfiguration.
    • disabled

      @Nonnull public static ResilienceConfiguration.RetryConfiguration disabled()
      Instantiate a new RetryConfiguration that only permits a single attempt, effectively disabling retries.
      Returns:
      A disabled instance of RetryConfiguration.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • maxAttempts

      public int maxAttempts()
      The maximum number of total attempts. Set this to 1 to not retry failed attempts.
    • waitDuration

      @Nonnull public Duration waitDuration()
      The duration to wait before retrying.
    • retryOnExceptionPredicate

      @Nonnull public Predicate<Throwable> retryOnExceptionPredicate()
      A predicate which evaluates if an exception should be retried. The predicate must return true, if the exception should be retried, otherwise it must return false. By default, all exceptions are retried.
    • waitDuration

      @Nonnull public ResilienceConfiguration.RetryConfiguration waitDuration(@Nonnull Duration waitDuration)
      The duration to wait before retrying.
      Returns:
      this.
    • retryOnExceptionPredicate

      @Nonnull public ResilienceConfiguration.RetryConfiguration retryOnExceptionPredicate(@Nonnull Predicate<Throwable> retryOnExceptionPredicate)
      A predicate which evaluates if an exception should be retried. The predicate must return true, if the exception should be retried, otherwise it must return false. By default, all exceptions are retried.
      Returns:
      this.