Class RetryWithDelayHandler

    • Field Detail

      • maxAttempts

        protected final int maxAttempts
      • retryDelay

        protected final Delay retryDelay
      • errorInterruptingPredicate

        protected final rx.functions.Func1<Throwable,​Boolean> errorInterruptingPredicate
      • optionalScheduler

        protected final rx.Scheduler optionalScheduler
    • Constructor Detail

      • RetryWithDelayHandler

        public RetryWithDelayHandler​(int maxAttempts,
                                     Delay retryDelay)
        Construct a retry handler that will retry on all errors.
        Parameters:
        maxAttempts - the maximum number of retries before a CannotRetryException is thrown. It will be capped at Integer.MAX_VALUE - 1.
        retryDelay - the Delay to apply between each retry (can grow, eg. by using ExponentialDelay).
      • RetryWithDelayHandler

        public RetryWithDelayHandler​(int maxAttempts,
                                     Delay retryDelay,
                                     rx.functions.Func1<Throwable,​Boolean> errorInterruptingPredicate,
                                     rx.functions.Action4<Integer,​Throwable,​Long,​TimeUnit> doOnRetry)
        Construct a retry handler that will retry on most errors but will stop on specific errors.
        Parameters:
        maxAttempts - the maximum number of retries before a CannotRetryException is thrown. It will be capped at Integer.MAX_VALUE - 1.
        retryDelay - the Delay to apply between each retry (can grow, eg. by using ExponentialDelay).
        errorInterruptingPredicate - a predicate that determine if an error must stop the retry cycle (when true), in which case said error is cascaded down.
      • RetryWithDelayHandler

        protected RetryWithDelayHandler​(int maxAttempts,
                                        Delay retryDelay,
                                        rx.functions.Func1<Throwable,​Boolean> errorInterruptingPredicate,
                                        rx.functions.Action4<Integer,​Throwable,​Long,​TimeUnit> doOnRetry,
                                        rx.Scheduler scheduler)
        Protected constructor that also allows to set a Scheduler for the delay, especially useful for tests.
    • Method Detail

      • messageForMaxAttempts

        protected static String messageForMaxAttempts​(long reachedAfterNRetries)