Class DefaultRetry<T>

    • Method Detail

      • withApplicationContext

        public Retry<T> withApplicationContext​(T applicationContext)
        Description copied from interface: Retry
        Returns a retry function with an application context that may be used to perform any rollbacks before a retry. This application context is provided to any retry predicate Retry.onlyIf(Predicate), custom backoff function Retry.backoff(Backoff) and retry callback Retry.doOnRetry(Consumer). All other properties of this retry function are retained in the returned instance.
        Specified by:
        withApplicationContext in interface Retry<T>
        Parameters:
        applicationContext - Application context
        Returns:
        retry function with associated application context
      • doOnRetry

        public Retry<T> doOnRetry​(Consumer<? super RetryContext<T>> onRetry)
        Description copied from interface: Retry
        Returns a retry function that invokes the provided onRetry callback before every retry. The RetryContext provided to the callback contains the iteration and the any application context set using Retry.withApplicationContext(Object). All other properties of this retry function are retained in the returned instance.
        Specified by:
        doOnRetry in interface Retry<T>
        Parameters:
        onRetry - callback to invoke before retries
        Returns:
        retry function with callback
      • retryMax

        public Retry<T> retryMax​(long maxIterations)
        Description copied from interface: Retry
        Retry function that retries n times.
        Specified by:
        retryMax in interface Retry<T>
        Parameters:
        maxIterations - number of retries
        Returns:
        Retry function for n retries
      • timeout

        public Retry<T> timeout​(Duration timeout)
        Description copied from interface: Retry
        Returns a retry function with timeout. The timeout starts from the instant that this function is applied, and the function keeps retrying until the timeout expires (or until the configured maximum number of attempts, if it has been set). All other properties of this retry function are retained in the returned instance.
        Specified by:
        timeout in interface Retry<T>
        Parameters:
        timeout - timeout after which no new retries are initiated
        Returns:
        retry function with global timeout
      • backoff

        public Retry<T> backoff​(Backoff backoff)
        Description copied from interface: Retry
        Returns a retry function with backoff delay. All other properties of this retry function are retained in the returned instance.
        Specified by:
        backoff in interface Retry<T>
        Parameters:
        backoff - the backoff function to determine backoff delay
        Returns:
        retry function with backoff
      • jitter

        public Retry<T> jitter​(Jitter jitter)
        Description copied from interface: Retry
        Returns a retry function that applies jitter to the backoff delay. All other properties of this retry function are retained in the returned instance.
        Specified by:
        jitter in interface Retry<T>
        Parameters:
        jitter - Jitter function to randomize backoff delay
        Returns:
        retry function with jitter for backoff
      • withBackoffScheduler

        public Retry<T> withBackoffScheduler​(Scheduler scheduler)
        Description copied from interface: Retry
        Returns a retry function that uses the scheduler provided for backoff delays. All other properties of this retry function are retained in the returned instance.
        Specified by:
        withBackoffScheduler in interface Retry<T>
        Parameters:
        scheduler - the scheduler for backoff delays
        Returns:
        retry function with backoff scheduler