Class MultiEmitterProcessor<T>

  • All Implemented Interfaces:
    ContextSupport, MultiEmitter<T>, org.reactivestreams.Processor<T,​T>, org.reactivestreams.Publisher<T>, org.reactivestreams.Subscriber<T>

    public class MultiEmitterProcessor<T>
    extends java.lang.Object
    implements org.reactivestreams.Processor<T,​T>, MultiEmitter<T>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void complete()
      Emits a completion event downstream indicating that no more item will be sent.
      Context context()
      Provide a context.
      static <T> MultiEmitterProcessor<T> create()  
      MultiEmitter<T> emit​(T item)
      Emits an item event downstream.
      void fail​(java.lang.Throwable failure)
      Emits a failure event downstream with the given exception.
      boolean isCancelled()  
      void onComplete()  
      void onError​(java.lang.Throwable failure)  
      void onNext​(T item)  
      void onSubscribe​(org.reactivestreams.Subscription subscription)  
      MultiEmitter<T> onTermination​(java.lang.Runnable onTermination)
      Attaches a @{code termination} event handler invoked when the downstream Subscription is cancelled, or when the emitter has emitted either a completion or failure event.
      long requested()  
      void subscribe​(org.reactivestreams.Subscriber<? super T> subscriber)  
      Multi<T> toMulti()  
      • Methods inherited from class java.lang.Object

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

      • emit

        public MultiEmitter<T> emit​(T item)
        Description copied from interface: MultiEmitter
        Emits an item event downstream.

        Calling this method after a failure or a completion events has no effect.

        Specified by:
        emit in interface MultiEmitter<T>
        Parameters:
        item - the item, must not be null
        Returns:
        this emitter, so firing item events can be chained.
      • fail

        public void fail​(java.lang.Throwable failure)
        Description copied from interface: MultiEmitter
        Emits a failure event downstream with the given exception.

        Calling this method multiple times or after the MultiEmitter.complete() method has no effect.

        Specified by:
        fail in interface MultiEmitter<T>
        Parameters:
        failure - the exception, must not be null
      • complete

        public void complete()
        Description copied from interface: MultiEmitter
        Emits a completion event downstream indicating that no more item will be sent.

        Calling this method multiple times or after the MultiEmitter.fail(Throwable) method has no effect.

        Specified by:
        complete in interface MultiEmitter<T>
      • onTermination

        public MultiEmitter<T> onTermination​(java.lang.Runnable onTermination)
        Description copied from interface: MultiEmitter
        Attaches a @{code termination} event handler invoked when the downstream Subscription is cancelled, or when the emitter has emitted either a completion or failure event.

        This method allows cleanup resources once the emitter can be disposed (has reached a terminal state).

        If the registration of the onTermination callback is done after the termination, it invokes the callback immediately.

        Specified by:
        onTermination in interface MultiEmitter<T>
        Parameters:
        onTermination - the action to run on termination, must not be null
        Returns:
        this emitter
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface MultiEmitter<T>
        Returns:
        true if the downstream cancelled the stream or the emitter was terminated (with a completion or failure events).
      • requested

        public long requested()
        Specified by:
        requested in interface MultiEmitter<T>
        Returns:
        the current outstanding request amount.
      • subscribe

        public void subscribe​(org.reactivestreams.Subscriber<? super T> subscriber)
        Specified by:
        subscribe in interface org.reactivestreams.Publisher<T>
      • onSubscribe

        public void onSubscribe​(org.reactivestreams.Subscription subscription)
        Specified by:
        onSubscribe in interface org.reactivestreams.Subscriber<T>
      • onNext

        public void onNext​(T item)
        Specified by:
        onNext in interface org.reactivestreams.Subscriber<T>
      • onError

        public void onError​(java.lang.Throwable failure)
        Specified by:
        onError in interface org.reactivestreams.Subscriber<T>
      • onComplete

        public void onComplete()
        Specified by:
        onComplete in interface org.reactivestreams.Subscriber<T>
      • toMulti

        public Multi<T> toMulti()
      • context

        public Context context()
        Description copied from interface: ContextSupport
        Provide a context.

        Since calls to this method shall only be triggered when a Mutiny pipeline uses a withContext operator, there is no need in general for caching the context value in a field of the implementing class. Exceptions include operators that have cross-subscriber semantics such as memoizers or broadcasters.

        This method is expected to be called once per withContext operator.

        Specified by:
        context in interface ContextSupport
        Returns:
        the context, must not be null.