T
- 任务结果类型public class RetryableTask<T> extends Object
Modifier and Type | Method and Description |
---|---|
CompletableFuture<RetryableTask<T>> |
asyncExecute()
异步执行重试方法
|
RetryableTask<T> |
delay(Duration delay)
重试间隔时间
|
RetryableTask<T> |
execute()
同步执行重试方法
|
Optional<T> |
get()
获取结果
|
RetryableTask<T> |
maxAttempts(long maxAttempts)
最大重试次数
|
static <T> RetryableTask<T> |
retryForExceptions(Runnable run,
Class<? extends Throwable>... ths)
重试根据指定的异常,没有返回值
|
static <T> RetryableTask<T> |
retryForExceptions(Supplier<T> sup,
Class<? extends Throwable>... ths)
重试根据指定的异常,有返回值
|
static <T> RetryableTask<T> |
retryForPredicate(Runnable run,
BiPredicate<T,Throwable> predicate)
重试根据指定的策略,没有返回值
|
static <T> RetryableTask<T> |
retryForPredicate(Supplier<T> sup,
BiPredicate<T,Throwable> predicate)
重试根据指定的策略,没有返回值
|
@SafeVarargs public static <T> RetryableTask<T> retryForExceptions(Runnable run, Class<? extends Throwable>... ths)
@SafeVarargs public static <T> RetryableTask<T> retryForExceptions(Supplier<T> sup, Class<? extends Throwable>... ths)
public static <T> RetryableTask<T> retryForPredicate(Runnable run, BiPredicate<T,Throwable> predicate)
T
- 返回值类型run
- 执行的方法 Runnable
predicate
- 策略 BiPredicate
,返回true
时表示重试public static <T> RetryableTask<T> retryForPredicate(Supplier<T> sup, BiPredicate<T,Throwable> predicate)
T
- 返回值类型sup
- 执行的方法 Supplier
predicate
- 策略 BiPredicate
,返回true
时表示重试public RetryableTask<T> maxAttempts(long maxAttempts)
maxAttempts
- 次数public RetryableTask<T> delay(Duration delay)
delay
- 间隔时间public CompletableFuture<RetryableTask<T>> asyncExecute()
CompletableFuture
public RetryableTask<T> execute()
Copyright © 2025. All rights reserved.