Class RetryPolicy
java.lang.Object
com.pyranid.RetryPolicy
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDetermines how long to wait before retrying after a failed transaction attempt.static interfaceDetermines whether a failed transaction attempt should be retried. -
Method Summary
Modifier and TypeMethodDescription@NonNull RetryPolicy.BackoffGets the retry backoff.@NonNull RetryPolicy.ConditionGets the retry condition.@NonNull IntegerGets the total number of attempts, including the initial attempt.static @NonNull RetryPolicyofMaxAttempts(@NonNull Integer maxAttempts, @NonNull RetryPolicy.Backoff backoff, @NonNull RetryPolicy.Condition condition) Creates a retry policy.@NonNull StringtoString()
-
Method Details
-
ofMaxAttempts
public static @NonNull RetryPolicy ofMaxAttempts(@NonNull Integer maxAttempts, @NonNull RetryPolicy.Backoff backoff, @NonNull RetryPolicy.Condition condition) Creates a retry policy.maxAttemptsis the total number of attempts, including the initial attempt. For example,3means one initial attempt plus up to two retries.- Parameters:
maxAttempts- total attempts, including the initial attemptbackoff- determines how long to wait before the next retrycondition- determines whether a failed attempt is retryable- Returns:
- a retry policy
-
getMaxAttempts
Gets the total number of attempts, including the initial attempt.- Returns:
- total attempts
-
getCondition
Gets the retry condition.- Returns:
- retry condition
-
getBackoff
-
toString
-