Record Class RetryConfig
java.lang.Object
java.lang.Record
cloud.opencode.base.core.retry.RetryConfig
public record RetryConfig(int maxAttempts, BackoffStrategy backoff, @Nullable Duration maxDelay, @Nullable Duration timeout, Predicate<Throwable> retryOn, Predicate<Throwable> abortOn, Predicate<Object> retryOnResult, BiConsumer<Integer, Throwable> onRetry, Consumer<Object> onSuccess, Consumer<Throwable> onExhausted)
extends Record
RetryConfig - Immutable retry configuration record
重试配置 - 不可变的重试配置记录
Encapsulates all retry parameters in an immutable record, suitable for sharing
across multiple Retry invocations. Sharing is safe when all callback fields
(retryOn, abortOn, onRetry, onSuccess, onExhausted, retryOnResult) are stateless.
将所有重试参数封装在不可变记录中,适合在多个 Retry 调用之间共享。
当所有回调字段(retryOn、abortOn、onRetry、onSuccess、onExhausted、retryOnResult)无状态时,共享是安全的。
- Since:
- JDK 25, opencode-base-core V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RetryConfigDefault configuration: 3 attempts, 100ms fixed delay. -
Constructor Summary
ConstructorsConstructorDescriptionRetryConfig(int maxAttempts, BackoffStrategy backoff, @Nullable Duration maxDelay, @Nullable Duration timeout, Predicate<Throwable> retryOn, Predicate<Throwable> abortOn, Predicate<Object> retryOnResult, BiConsumer<Integer, Throwable> onRetry, Consumer<Object> onSuccess, Consumer<Throwable> onExhausted) Creates an instance of aRetryConfigrecord class.RetryConfig(int maxAttempts, BackoffStrategy backoff, @Nullable Duration maxDelay, Predicate<Throwable> retryOn, Predicate<Throwable> abortOn, BiConsumer<Integer, Throwable> onRetry) Backward-compatible constructor without timeout, retryOnResult, onSuccess, onExhausted. -
Method Summary
Modifier and TypeMethodDescriptionabortOn()Returns the value of theabortOnrecord component.backoff()Returns the value of thebackoffrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxAttemptsrecord component.@Nullable DurationmaxDelay()Returns the value of themaxDelayrecord component.Returns the value of theonExhaustedrecord component.onRetry()Returns the value of theonRetryrecord component.Returns the value of theonSuccessrecord component.retryOn()Returns the value of theretryOnrecord component.Returns the value of theretryOnResultrecord component.@Nullable Durationtimeout()Returns the value of thetimeoutrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT
Default configuration: 3 attempts, 100ms fixed delay. 默认配置:3次尝试,100毫秒固定延迟。
-
-
Constructor Details
-
RetryConfig
public RetryConfig(int maxAttempts, BackoffStrategy backoff, @Nullable Duration maxDelay, @Nullable Duration timeout, Predicate<Throwable> retryOn, Predicate<Throwable> abortOn, Predicate<Object> retryOnResult, BiConsumer<Integer, Throwable> onRetry, Consumer<Object> onSuccess, Consumer<Throwable> onExhausted) Creates an instance of aRetryConfigrecord class.- Parameters:
maxAttempts- the value for themaxAttemptsrecord componentbackoff- the value for thebackoffrecord componentmaxDelay- the value for themaxDelayrecord componenttimeout- the value for thetimeoutrecord componentretryOn- the value for theretryOnrecord componentabortOn- the value for theabortOnrecord componentretryOnResult- the value for theretryOnResultrecord componentonRetry- the value for theonRetryrecord componentonSuccess- the value for theonSuccessrecord componentonExhausted- the value for theonExhaustedrecord component
-
RetryConfig
public RetryConfig(int maxAttempts, BackoffStrategy backoff, @Nullable Duration maxDelay, Predicate<Throwable> retryOn, Predicate<Throwable> abortOn, BiConsumer<Integer, Throwable> onRetry) Backward-compatible constructor without timeout, retryOnResult, onSuccess, onExhausted. 向后兼容的构造函数,不含 timeout、retryOnResult、onSuccess、onExhausted。
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
maxAttempts
public int maxAttempts()Returns the value of themaxAttemptsrecord component.- Returns:
- the value of the
maxAttemptsrecord component
-
backoff
Returns the value of thebackoffrecord component.- Returns:
- the value of the
backoffrecord component
-
maxDelay
Returns the value of themaxDelayrecord component.- Returns:
- the value of the
maxDelayrecord component
-
timeout
Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
retryOn
-
abortOn
-
retryOnResult
-
onRetry
Returns the value of theonRetryrecord component.- Returns:
- the value of the
onRetryrecord component
-
onSuccess
-
onExhausted
-