Class EmitterImpl<T>

  • Type Parameters:
    T - the type of payload sent by the emitter.
    All Implemented Interfaces:
    Emitter<T>

    public class EmitterImpl<T>
    extends Object
    implements Emitter<T>
    Implementation of the emitter pattern.
    • Constructor Detail

    • Method Detail

      • getPublisher

        public org.reactivestreams.Publisher<Message<? extends T>> getPublisher()
      • send

        public CompletionStage<Void> send​(T msg)
        Description copied from interface: Emitter
        Sends a payload to the channel.

        A Message object will be created to hold the payload and the returned CompletionStage will be completed once this Message is acknowledged. If the Message is never acknowledged, then the CompletionStage will never be completed.

        Specified by:
        send in interface Emitter<T>
        Parameters:
        msg - the thing to send, must not be null
        Returns:
        the CompletionStage, which will be completed when the message for this payload is acknowledged.
      • send

        public <M extends Message<? extends T>> void send​(M msg)
        Description copied from interface: Emitter
        Sends a message to the channel.
        Specified by:
        send in interface Emitter<T>
        Type Parameters:
        M - the Message type
        Parameters:
        msg - the Message to send, must not be null
      • complete

        public void complete()
        Description copied from interface: Emitter
        Sends the completion event to the channel indicating that no other events will be sent afterward.
        Specified by:
        complete in interface Emitter<T>
      • error

        public void error​(Exception e)
        Description copied from interface: Emitter
        Sends a failure event to the channel. No more events will be sent afterward.
        Specified by:
        error in interface Emitter<T>
        Parameters:
        e - the exception, must not be null
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface Emitter<T>
        Returns:
        true if the emitter has been terminated or the subscription cancelled.
      • hasRequests

        public boolean hasRequests()
        Specified by:
        hasRequests in interface Emitter<T>
        Returns:
        true if one or more subscribers request messages from the corresponding channel where the emitter connects to, return false otherwise.