Class DefaultRetryRunner

java.lang.Object
io.micronaut.retry.intercept.DefaultRetryRunner

@Internal public final class DefaultRetryRunner extends Object
Shared retry execution engine for synchronous, reactive, and asynchronous flows.
Since:
5.0.0
Author:
graemerocher
  • Constructor Details

    • DefaultRetryRunner

      public DefaultRetryRunner(ScheduledExecutorService executorService, RetrySleeper retrySleeper)
      Creates a shared retry runner.
      Parameters:
      executorService - The scheduler used for delayed retries
      retrySleeper - 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 attempt
      retryState - The retry state
      logContext - The log context
      retryEventEmitter - 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 attempt
      retryState - The retry state
      logContext - The log context
      retryEventEmitter - 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 attempt
      retryState - The retry state
      logContext - The log context
      retryEventEmitter - The retry event emitter
      Returns:
      A publisher representing the retried execution