Interface Retry.Context<T>

Type Parameters:
T - the result type
All Known Implementing Classes:
RetryImpl.ContextImpl
Enclosing interface:
Retry

public static interface Retry.Context<T>
the retry context which will be used during the retry iteration to decide what can be done on error , result, on runtime error
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Records a successful call or retryable call with the needed generated retry events.
    void
    onError(Exception exception)
    Handles a checked exception
    boolean
    onResult(T result)
     
    void
    onRuntimeError(RuntimeException runtimeException)
    Handles a runtime exception
  • Method Details

    • onComplete

      void onComplete()
      Records a successful call or retryable call with the needed generated retry events. When there is a successful retry before reaching the max retries limit, it will generate a RetryOnSuccessEvent. When the retry reaches the max retries limit, it will generate a RetryOnErrorEvent with last exception or MaxRetriesExceeded if no other exceptions is thrown.
    • onResult

      boolean onResult(T result)
      Parameters:
      result - the returned result from the called logic
      Returns:
      true if we need to retry again or false if no retry anymore
    • onError

      void onError(Exception exception) throws Exception
      Handles a checked exception
      Parameters:
      exception - the exception to handle
      Throws:
      Exception - when retry count has exceeded
    • onRuntimeError

      void onRuntimeError(RuntimeException runtimeException)
      Handles a runtime exception
      Parameters:
      runtimeException - the exception to handle
      Throws:
      RuntimeException - when retry count has exceeded