Package dev.langchain4j.internal
Class RetryUtils
-
- All Implemented Interfaces:
public final class RetryUtils
Utility class for retrying actions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
RetryUtils.RetryPolicy
This class encapsulates a retry policy.
-
Field Summary
Fields Modifier and Type Field Description public final static RetryUtils.RetryPolicy
DEFAULT_RETRY_POLICY
-
Method Summary
Modifier and Type Method Description static RetryUtils.RetryPolicy.Builder
retryPolicyBuilder()
This method returns a RetryPolicy.Builder. static <T> T
withRetry(Callable<T> action, int maxAttempts)
This method attempts to execute a given action up to a specified number of times with a 1-second delay. static <T> T
withRetry(Callable<T> action)
This method attempts to execute a given action up to a specified number of times with a 1-second delay. -
-
Method Detail
-
retryPolicyBuilder
static RetryUtils.RetryPolicy.Builder retryPolicyBuilder()
This method returns a RetryPolicy.Builder.
- Returns:
A RetryPolicy.Builder.
-
withRetry
static <T> T withRetry(Callable<T> action, int maxAttempts)
This method attempts to execute a given action up to a specified number of times with a 1-second delay. If the action fails on all attempts, it throws a RuntimeException.
- Parameters:
action
- The action to be executed.maxAttempts
- The maximum number of attempts to execute the action.- Returns:
The result of the action if it is successful.
-
withRetry
static <T> T withRetry(Callable<T> action)
This method attempts to execute a given action up to a specified number of times with a 1-second delay. If the action fails on all attempts, it throws a RuntimeException.
- Parameters:
action
- The action to be executed.- Returns:
The result of the action if it is successful.
-
-
-
-