Class DefaultRetryRunner
java.lang.Object
io.micronaut.retry.intercept.DefaultRetryRunner
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRetryRunner(ScheduledExecutorService executorService, RetrySleeper retrySleeper) Creates a shared retry runner. -
Method Summary
Modifier and TypeMethodDescription<T> CompletionStage<T> executeCompletionStage(Supplier<? extends CompletionStage<T>> supplier, MutableRetryState retryState, String logContext, RetryEventEmitter retryEventEmitter) Executes completion stage work with retry.<T> Publisher<T> executePublisher(Supplier<? extends Publisher<T>> supplier, MutableRetryState retryState, String logContext, RetryEventEmitter retryEventEmitter) Executes publisher work with retry.<T> TexecuteSync(Supplier<T> supplier, MutableRetryState retryState, String logContext, RetryEventEmitter retryEventEmitter) Executes synchronous work with retry.
-
Constructor Details
-
DefaultRetryRunner
Creates a shared retry runner.- Parameters:
executorService- The scheduler used for delayed retriesretrySleeper- The strategy used to sleep between retries
-
-
Method Details
-
executeSync
public <T> T executeSync(Supplier<T> supplier, MutableRetryState retryState, String logContext, RetryEventEmitter retryEventEmitter) Executes synchronous work with retry.- Type Parameters:
T- The result type- Parameters:
supplier- The supplier to invoke for each attemptretryState- The retry statelogContext- The log contextretryEventEmitter- The retry event emitter- Returns:
- The computed result
-
executeCompletionStage
public <T> CompletionStage<T> executeCompletionStage(Supplier<? extends CompletionStage<T>> supplier, MutableRetryState retryState, String logContext, RetryEventEmitter retryEventEmitter) Executes completion stage work with retry.- Type Parameters:
T- The result type- Parameters:
supplier- The supplier that creates a new completion stage for each attemptretryState- The retry statelogContext- The log contextretryEventEmitter- The retry event emitter- Returns:
- A completion stage representing the retried execution
-
executePublisher
public <T> Publisher<T> executePublisher(Supplier<? extends Publisher<T>> supplier, MutableRetryState retryState, String logContext, RetryEventEmitter retryEventEmitter) Executes publisher work with retry.- Type Parameters:
T- The emitted type- Parameters:
supplier- The supplier that creates a new publisher for each attemptretryState- The retry statelogContext- The log contextretryEventEmitter- The retry event emitter- Returns:
- A publisher representing the retried execution
-