Interface RetryStrategy
- All Known Implementing Classes:
LinearBackoffRetryStrategy
public interface RetryStrategy
重試策略介面
定義重試操作的通用介面,支援不同的退避策略(線性、指數等)。
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface重試回調介面,用於追蹤重試狀態 -
Method Summary
Modifier and TypeMethodDescription<T> T執行帶重試機制的操作<T> Texecute(Callable<T> operation, int maxRetries, RetryStrategy.RetryCallback callback) 執行帶重試機制的操作(帶回調)
-
Method Details
-
execute
-
execute
<T> T execute(Callable<T> operation, int maxRetries, RetryStrategy.RetryCallback callback) throws Exception 執行帶重試機制的操作(帶回調)- Type Parameters:
T- 返回值類型- Parameters:
operation- 要執行的操作maxRetries- 最大重試次數(不包含首次嘗試)callback- 重試回調- Returns:
- 操作結果
- Throws:
Exception- 如果所有重試都失敗
-