Module mutiny.zero

Class Retry<T>

  • Type Parameters:
    T - the elements type
    All Implemented Interfaces:
    java.util.concurrent.Flow.Publisher<T>

    public class Retry<T>
    extends java.lang.Object
    implements java.util.concurrent.Flow.Publisher<T>
    A Flow.Publisher that retries on failure by re-subscribing to its upstream. A Predicate controls when to retry, and when to stop retrying.

    Note: this retry operator does not perform advanced time-based re-subscriptions (e.g., exponential back-off).

    • Constructor Summary

      Constructors 
      Constructor Description
      Retry​(java.util.concurrent.Flow.Publisher<T> upstream, java.util.function.Predicate<java.lang.Throwable> retryPredicate)
      Build a new retry publisher.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.function.Predicate<java.lang.Throwable> always()  
      static java.util.function.Predicate<java.lang.Throwable> atMost​(int count)  
      void subscribe​(java.util.concurrent.Flow.Subscriber<? super T> subscriber)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Retry

        public Retry​(java.util.concurrent.Flow.Publisher<T> upstream,
                     java.util.function.Predicate<java.lang.Throwable> retryPredicate)
        Build a new retry publisher.
        Parameters:
        upstream - the upstream publisher
        retryPredicate - the retry predicate
    • Method Detail

      • always

        public static java.util.function.Predicate<java.lang.Throwable> always()
      • atMost

        public static java.util.function.Predicate<java.lang.Throwable> atMost​(int count)
      • subscribe

        public void subscribe​(java.util.concurrent.Flow.Subscriber<? super T> subscriber)
        Specified by:
        subscribe in interface java.util.concurrent.Flow.Publisher<T>