Module mutiny.zero

Class Recover<T>

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

    public class Recover<T>
    extends java.lang.Object
    implements java.util.concurrent.Flow.Publisher<T>
    A Flow.Publisher that recovers from failure using a Function.

    The provided function accepts an error that would normally trigger an Flow.Subscriber.onError(Throwable) signal.

    The function returns a recovery value of type T, then the stream terminates with an Flow.Subscriber.onComplete() signal. If the function returns null then the stream terminates directly with a completion event.

    The stream ends with an error if the function throws an exception.

    • Constructor Summary

      Constructors 
      Constructor Description
      Recover​(java.util.concurrent.Flow.Publisher<T> upstream, java.util.function.Function<java.lang.Throwable,​T> function)
      Build a new recovery publisher.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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

      • Recover

        public Recover​(java.util.concurrent.Flow.Publisher<T> upstream,
                       java.util.function.Function<java.lang.Throwable,​T> function)
        Build a new recovery publisher.
        Parameters:
        upstream - the upstream publisher
        function - the recovery function, must not return null values
    • Method Detail

      • subscribe

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