Interface RetryContext


public interface RetryContext
Context of an invocation attempt handled by Retry.

The first attempt has an attempt number of 1, a previous delay of Duration.ZERO, and no previous throwable. Each subsequent attempt provides the delay preceding that attempt and the throwable from the previous attempt. The context is created immediately before invoking the function for an attempt.

  • Method Details

    • attempt

      int attempt()
      Number of the current invocation attempt.
      Returns:
      1-based invocation attempt number
    • elapsedTime

      Duration elapsedTime()
      Time elapsed since the retry invocation started when this attempt began.
      Returns:
      elapsed time
    • previousDelay

      Duration previousDelay()
      Requested delay preceding this attempt.

      The value is Duration.ZERO for the initial attempt.

      Returns:
      requested delay preceding this attempt
    • previousThrowable

      Optional<Throwable> previousThrowable()
      Throwable from the preceding attempt.
      Returns:
      preceding throwable, or empty for the initial attempt