Class RetryPolicy

java.lang.Object
com.pyranid.RetryPolicy

@ThreadSafe public final class RetryPolicy extends Object
Defines when and how Database.transactionWithRetry(RetryPolicy, TransactionalOperation) retries a transaction.

A retry policy requires all retry-critical decisions to be explicit: total attempts, retry condition, and backoff.

Since:
4.4.0
Author:
Mark Allen
  • Method Details

    • ofMaxAttempts

      public static @NonNull RetryPolicy ofMaxAttempts(@NonNull Integer maxAttempts, @NonNull RetryPolicy.Backoff backoff, @NonNull RetryPolicy.Condition condition)
      Creates a retry policy.

      maxAttempts is the total number of attempts, including the initial attempt. For example, 3 means one initial attempt plus up to two retries.

      Parameters:
      maxAttempts - total attempts, including the initial attempt
      backoff - determines how long to wait before the next retry
      condition - determines whether a failed attempt is retryable
      Returns:
      a retry policy
    • getMaxAttempts

      public @NonNull Integer getMaxAttempts()
      Gets the total number of attempts, including the initial attempt.
      Returns:
      total attempts
    • getCondition

      Gets the retry condition.
      Returns:
      retry condition
    • getBackoff

      public @NonNull RetryPolicy.Backoff getBackoff()
      Gets the retry backoff.
      Returns:
      retry backoff
    • toString

      public @NonNull String toString()
      Overrides:
      toString in class Object