类 RetryUtils.RetryPolicy

java.lang.Object
dev.langchain4j.internal.RetryUtils.RetryPolicy
封闭类:
RetryUtils

public static final class RetryUtils.RetryPolicy extends Object
This class encapsulates a retry policy.
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static final class 
    This class encapsulates a retry policy builder.
  • 构造器概要

    构造器
    构造器
    说明
    RetryPolicy(int maxAttempts, int delayMillis, double jitterScale, double backoffExp)
    Construct a RetryPolicy.
  • 方法概要

    修饰符和类型
    方法
    说明
    int
    jitterDelayMillis(int attempt)
    This method returns the jitter delay in milliseconds for a given attempt.
    double
    rawDelayMs(int attempt)
    This method returns the raw delay in milliseconds for a given attempt.
    void
    sleep(int attempt)
    This method sleeps for a given attempt.
    <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.
    <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.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • RetryPolicy

      public RetryPolicy(int maxAttempts, int delayMillis, double jitterScale, double backoffExp)
      Construct a RetryPolicy.
      参数:
      maxAttempts - The maximum number of attempts.
      delayMillis - The delay in milliseconds.
      jitterScale - The jitter scale.
      backoffExp - The backoff exponent.
  • 方法详细资料

    • rawDelayMs

      public double rawDelayMs(int attempt)
      This method returns the raw delay in milliseconds for a given attempt.
      参数:
      attempt - The attempt number.
      返回:
      The raw delay in milliseconds.
    • jitterDelayMillis

      public int jitterDelayMillis(int attempt)
      This method returns the jitter delay in milliseconds for a given attempt.
      参数:
      attempt - The attempt number.
      返回:
      The jitter delay in milliseconds.
    • sleep

      public void sleep(int attempt)
      This method sleeps for a given attempt.
      参数:
      attempt - The attempt number.
    • withRetry

      public <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.
      类型参数:
      T - The type of the result of the action.
      参数:
      action - The action to be executed.
      返回:
      The result of the action if it is successful.
      抛出:
      RuntimeException - if the action fails on all attempts.
    • withRetry

      public <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.
      类型参数:
      T - The type of the result of the action.
      参数:
      action - The action to be executed.
      maxAttempts - The maximum number of attempts to execute the action.
      返回:
      The result of the action if it is successful.
      抛出:
      RuntimeException - if the action fails on all attempts.