类 RetryUtils.RetryPolicy.Builder

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

public static final class RetryUtils.RetryPolicy.Builder extends Object
This class encapsulates a retry policy builder.
  • 构造器详细资料

    • Builder

      public Builder()
      Construct a RetryPolicy.Builder.
  • 方法详细资料

    • maxAttempts

      public RetryUtils.RetryPolicy.Builder maxAttempts(int maxAttempts)
      Sets the default maximum number of attempts.
      参数:
      maxAttempts - The maximum number of attempts.
      返回:
      this
    • delayMillis

      public RetryUtils.RetryPolicy.Builder delayMillis(int delayMillis)
      Sets the base delay in milliseconds.

      The delay is calculated as follows:

      1. Calculate the raw delay in milliseconds as delayMillis * Math.pow(backoffExp, attempt - 1).
      2. Calculate the jitter delay in milliseconds as rawDelayMs + rand.nextInt((int) (rawDelayMs * jitterScale)).
      3. Sleep for the jitter delay in milliseconds.
      参数:
      delayMillis - The delay in milliseconds.
      返回:
      this
    • jitterScale

      public RetryUtils.RetryPolicy.Builder jitterScale(double jitterScale)
      Sets the jitter scale.

      The jitter delay in milliseconds is calculated as rawDelayMs + rand.nextInt((int) (rawDelayMs * jitterScale)).

      参数:
      jitterScale - The jitter scale.
      返回:
      this
    • backoffExp

      public RetryUtils.RetryPolicy.Builder backoffExp(double backoffExp)
      Sets the backoff exponent.
      参数:
      backoffExp - The backoff exponent.
      返回:
      this
    • build

      public RetryUtils.RetryPolicy build()
      Builds a RetryPolicy.
      返回:
      A RetryPolicy.