Class RetryPolicy.CustomRetryPolicy

java.lang.Object
cloud.opencode.base.cache.spi.RetryPolicy.CustomRetryPolicy
All Implemented Interfaces:
RetryPolicy
Enclosing interface:
RetryPolicy

public static final class RetryPolicy.CustomRetryPolicy extends Object implements RetryPolicy
Custom retry policy implementation - wraps a delegate with custom exception filter 自定义重试策略实现 - 用自定义异常过滤器包装委托
Since:
JDK 25, opencode-base-cache V1.9.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • maxRetries

      public int maxRetries()
      Description copied from interface: RetryPolicy
      Get the maximum number of retry attempts 获取最大重试次数
      Specified by:
      maxRetries in interface RetryPolicy
      Returns:
      max retries (0 means no retry) | 最大重试次数(0 表示不重试)
    • getDelay

      public Duration getDelay(int attempt)
      Description copied from interface: RetryPolicy
      Calculate delay before the next retry attempt 计算下次重试前的延迟
      Specified by:
      getDelay in interface RetryPolicy
      Parameters:
      attempt - current attempt number (1-based) | 当前尝试次数(从 1 开始)
      Returns:
      delay before retry | 重试前的延迟
    • shouldRetry

      public boolean shouldRetry(Throwable exception)
      Description copied from interface: RetryPolicy
      Check if the exception should trigger a retry 检查异常是否应触发重试
      Specified by:
      shouldRetry in interface RetryPolicy
      Parameters:
      exception - the exception | 异常
      Returns:
      true if should retry | 应重试返回 true