T
- the type of element signaledpublic class PublisherBasedStreamMessage<T> extends Object implements StreamMessage<T>
Publisher
into a StreamMessage
.Constructor and Description |
---|
PublisherBasedStreamMessage(org.reactivestreams.Publisher<? extends T> publisher)
Creates a new instance with the specified delegate
Publisher . |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Closes this stream with
AbortedStreamException and prevents further subscription. |
CompletableFuture<Void> |
completionFuture()
Returns a
CompletableFuture that completes when this stream is complete,
either successfully or exceptionally, including cancellation and abortion. |
protected EventExecutor |
defaultSubscriberExecutor()
Returns the default
EventExecutor which will be used when a user subscribes using
subscribe(Subscriber) or subscribe(Subscriber, boolean) . |
protected org.reactivestreams.Publisher<? extends T> |
delegate()
Returns the delegate
Publisher . |
boolean |
isEmpty()
Returns
true if this stream has been closed and did not publish any elements. |
boolean |
isOpen()
Returns
true if this stream is not closed yet. |
void |
subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
Requests to start streaming data to the specified
Subscriber . |
void |
subscribe(org.reactivestreams.Subscriber<? super T> subscriber,
boolean withPooledObjects)
Requests to start streaming data to the specified
Subscriber . |
void |
subscribe(org.reactivestreams.Subscriber<? super T> subscriber,
EventExecutor executor)
Requests to start streaming data, invoking the specified
Subscriber from the specified
Executor . |
void |
subscribe(org.reactivestreams.Subscriber<? super T> subscriber,
EventExecutor executor,
boolean withPooledObjects)
Requests to start streaming data, invoking the specified
Subscriber from the specified
Executor . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
closeFuture, isComplete
public PublisherBasedStreamMessage(org.reactivestreams.Publisher<? extends T> publisher)
Publisher
.protected final org.reactivestreams.Publisher<? extends T> delegate()
Publisher
.public boolean isOpen()
StreamMessage
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
.isOpen
in interface StreamMessage<T>
public boolean isEmpty()
StreamMessage
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.isEmpty
in interface StreamMessage<T>
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
StreamMessage
Subscriber
. If there is a problem subscribing,
Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:
IllegalStateException
if other Subscriber
subscribed to this stream alreadyAbortedStreamException
if this stream has been aborted.subscribe
in interface StreamMessage<T>
subscribe
in interface org.reactivestreams.Publisher<T>
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, boolean withPooledObjects)
StreamMessage
Subscriber
. If there is a problem subscribing,
Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:
IllegalStateException
if other Subscriber
subscribed to this stream alreadyAbortedStreamException
if this stream has been aborted.subscribe
in interface StreamMessage<T>
withPooledObjects
- if true
, receives the pooled ByteBuf
and ByteBufHolder
as is, without making a copy. If you don't know what this means, use
StreamMessage.subscribe(Subscriber)
.public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor)
StreamMessage
Subscriber
from the specified
Executor
. If there is a problem subscribing, Subscriber.onError(Throwable)
will be
invoked with one of the following exceptions:
IllegalStateException
if other Subscriber
subscribed to this stream alreadyAbortedStreamException
if this stream has been aborted.subscribe
in interface StreamMessage<T>
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor, boolean withPooledObjects)
StreamMessage
Subscriber
from the specified
Executor
. If there is a problem subscribing, Subscriber.onError(Throwable)
will be
invoked with one of the following exceptions:
IllegalStateException
if other Subscriber
subscribed to this stream alreadyAbortedStreamException
if this stream has been aborted.subscribe
in interface StreamMessage<T>
withPooledObjects
- if true
, receives the pooled ByteBuf
and ByteBufHolder
as is, without making a copy. If you don't know what this means, use
StreamMessage.subscribe(Subscriber)
.protected EventExecutor defaultSubscriberExecutor()
EventExecutor
which will be used when a user subscribes using
subscribe(Subscriber)
or subscribe(Subscriber, boolean)
.public void abort()
StreamMessage
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.abort
in interface StreamMessage<T>
public CompletableFuture<Void> completionFuture()
StreamMessage
CompletableFuture
that completes when this stream is complete,
either successfully or exceptionally, including cancellation and abortion.
A StreamMessage
is complete
(or 'fully consumed') when:
Subscriber
consumes all elements and Subscriber.onComplete()
is invoked,Subscriber.onError(Throwable)
is invoked,Subscription
has been cancelled orStreamMessage.abort()
has been requested.completionFuture
in interface StreamMessage<T>
© Copyright 2015–2017 LINE Corporation. All rights reserved.