类 RetryUtils.RetryPolicy.Builder
java.lang.Object
dev.langchain4j.internal.RetryUtils.RetryPolicy.Builder
This class encapsulates a retry policy builder.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明backoffExp(double backoffExp) Sets the backoff exponent.build()Builds a RetryPolicy.delayMillis(int delayMillis) Sets the base delay in milliseconds.jitterScale(double jitterScale) Sets the jitter scale.maxAttempts(int maxAttempts) Sets the default maximum number of attempts.
-
构造器详细资料
-
Builder
public Builder()Construct a RetryPolicy.Builder.
-
-
方法详细资料
-
maxAttempts
Sets the default maximum number of attempts.- 参数:
maxAttempts- The maximum number of attempts.- 返回:
this
-
delayMillis
Sets the base delay in milliseconds.The delay is calculated as follows:
- Calculate the raw delay in milliseconds as
delayMillis * Math.pow(backoffExp, attempt - 1). - Calculate the jitter delay in milliseconds as
rawDelayMs + rand.nextInt((int) (rawDelayMs * jitterScale)). - Sleep for the jitter delay in milliseconds.
- 参数:
delayMillis- The delay in milliseconds.- 返回:
this
- Calculate the raw delay in milliseconds as
-
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
Sets the backoff exponent.- 参数:
backoffExp- The backoff exponent.- 返回:
this
-
build
Builds a RetryPolicy.- 返回:
- A RetryPolicy.
-