RetryPredicate

interface RetryPredicate

Represents a retry predicate that determines whether a block of code should be retried based on the result of its execution and the current retry count.

The shouldRetry method must be implemented to specify the retry condition.

In addition to shouldRetry, this interface provides default implementations for boolean logic operations, allowing for the creation of complex retry conditions by combining multiple retry predicates.

Usage:

val alwaysRetry = object : RetryPredicate {
override fun shouldRetry(result: Result<Any?>, retryCount: Int) = true
}

Since

1.0.0

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open infix fun and(other: RetryPredicate): RetryPredicate

Combines this predicate with another using logical AND (conjunction).

Link copied to clipboard
open infix fun nand(other: RetryPredicate): RetryPredicate

Combines this predicate with another using logical NAND.

Link copied to clipboard
open infix fun nor(other: RetryPredicate): RetryPredicate

Combines this predicate with another using logical NOR.

Link copied to clipboard
open operator fun not(): RetryPredicate

Negates the retry condition, inverting the result of shouldRetry.

Link copied to clipboard
open infix fun or(other: RetryPredicate): RetryPredicate

Combines this predicate with another using logical OR (disjunction).

Link copied to clipboard
abstract fun shouldRetry(result: Result<Any?>, retryCount: Int, elapsedTime: Duration): Boolean

Called by RetryPolicy.retry, determines whether a retry should be performed based on the result of execution and the retryCount.

Link copied to clipboard

Combines a RetryPredicate with a DelayStrategy to create a RetryPolicy.

Link copied to clipboard
open infix fun xnor(other: RetryPredicate): RetryPredicate

Combines this predicate with another using logical XNOR.

Link copied to clipboard
open infix fun xor(other: RetryPredicate): RetryPredicate

Combines this predicate with another using logical XOR (exclusive OR).