Class TwoElementFixedStreamMessage<T>

java.lang.Object
com.linecorp.armeria.common.stream.TwoElementFixedStreamMessage<T>
All Implemented Interfaces:
StreamMessage<T>, org.reactivestreams.Publisher<T>, org.reactivestreams.Subscription

@UnstableApi public class TwoElementFixedStreamMessage<T> extends Object
A FixedStreamMessage that publishes two objects.
  • Constructor Details

    • TwoElementFixedStreamMessage

      protected TwoElementFixedStreamMessage(T obj1, T obj2)
      Constructs a new TwoElementFixedStreamMessage for the given objects.
  • Method Details

    • demand

      public long demand()
      Description copied from interface: StreamMessage
      Returns the current demand of this stream.
    • request

      public void request(long n)
    • cancel

      public void cancel()
      Specified by:
      cancel in interface org.reactivestreams.Subscription
    • abort

      public void abort()
      Description copied from interface: StreamMessage
      Closes this stream with AbortedStreamException and prevents further subscription. A Subscriber that attempts to subscribe to an aborted stream will be notified with an AbortedStreamException via Subscriber.onError(Throwable). Calling this method on a closed or aborted stream has no effect.
      Specified by:
      abort in interface StreamMessage<T>
    • abort

      public void abort(Throwable cause)
      Description copied from interface: StreamMessage
      Closes this stream with the specified Throwable and prevents further subscription. A Subscriber that attempts to subscribe to an aborted stream will be notified with the specified Throwable via Subscriber.onError(Throwable). Calling this method on a closed or aborted stream has no effect.
      Specified by:
      abort in interface StreamMessage<T>
    • isOpen

      public final boolean isOpen()
      Description copied from interface: StreamMessage
      Returns true if this stream is not closed yet. Note that a stream may not be complete even if it's closed; a stream is complete when it's fully consumed by a Subscriber.
      Specified by:
      isOpen in interface StreamMessage<T>
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: StreamMessage
      Returns true if this stream has been closed and did not publish any elements. Note that this method will not return true when the stream is open even if it has not published anything so far, because it may publish something later.
      Specified by:
      isEmpty in interface StreamMessage<T>
    • whenComplete

      public CompletableFuture<Void> whenComplete()
      Description copied from interface: StreamMessage
      Returns a CompletableFuture that completes when this stream is complete, either successfully or exceptionally, including cancellation and abortion.

      A StreamMessage is complete (or 'fully consumed') when:

      • the Subscriber consumes all elements and Subscriber.onComplete() is invoked,
      • an error occurred and Subscriber.onError(Throwable) is invoked,
      • the Subscription has been cancelled or
      • StreamMessage.abort() has been requested.
      Specified by:
      whenComplete in interface StreamMessage<T>
    • subscribe

      public void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor, SubscriptionOption... options)
      Description copied from interface: StreamMessage
      Requests to start streaming data to the specified Subscriber. If there is a problem subscribing, Subscriber.onError(Throwable) will be invoked with one of the following exceptions:
      Specified by:
      subscribe in interface StreamMessage<T>
      executor - the executor to subscribe
      options - SubscriptionOptions to subscribe with
    • collect

      public CompletableFuture<List<T>> collect(EventExecutor executor, SubscriptionOption... options)
      Description copied from interface: StreamMessage
      Collects the elements published by this StreamMessage with the specified EventExecutor and SubscriptionOptions. The returned CompletableFuture will be notified when the elements are fully consumed.

      Note that if this StreamMessage was subscribed by other Subscriber already, the returned CompletableFuture will be completed with an IllegalStateException.

      Specified by:
      collect in interface StreamMessage<T>