T - the type of elementspublic class StreamMessageWrapper<T> extends Object implements StreamMessage<T>
StreamMessage and forwards its method invocations to delegate.| Modifier | Constructor and Description |
|---|---|
protected |
StreamMessageWrapper(StreamMessage<? extends T> delegate)
Creates a new instance that wraps a
delegate. |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Closes this stream with
AbortedStreamException and prevents further subscription. |
void |
abort(Throwable cause)
Closes this stream with the specified
Throwable and prevents further subscription. |
io.netty.util.concurrent.EventExecutor |
defaultSubscriberExecutor()
Returns the default
EventExecutor which will be used when a user subscribes using
StreamMessage.subscribe(Subscriber), StreamMessage.subscribe(Subscriber, SubscriptionOption...),
StreamMessage.drainAll() and StreamMessage.drainAll(SubscriptionOption...). |
protected StreamMessage<? extends T> |
delegate()
Returns the
StreamMessage being decorated. |
CompletableFuture<List<T>> |
drainAll(io.netty.util.concurrent.EventExecutor executor)
Subscribes to this
StreamMessage and retrieves all elements from it. |
CompletableFuture<List<T>> |
drainAll(io.netty.util.concurrent.EventExecutor executor,
SubscriptionOption... options)
Subscribes to this
StreamMessage and retrieves all elements from it. |
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,
io.netty.util.concurrent.EventExecutor executor)
Requests to start streaming data to the specified
Subscriber. |
void |
subscribe(org.reactivestreams.Subscriber<? super T> subscriber,
io.netty.util.concurrent.EventExecutor executor,
SubscriptionOption... options)
Requests to start streaming data to the specified
Subscriber. |
StreamMessageDuplicator<T> |
toDuplicator()
Returns a new
StreamMessageDuplicator that duplicates this StreamMessage into one or
more StreamMessages, which publish the same elements. |
StreamMessageDuplicator<T> |
toDuplicator(io.netty.util.concurrent.EventExecutor executor)
Returns a new
StreamMessageDuplicator that duplicates this StreamMessage into one or
more StreamMessages, which publish the same elements. |
String |
toString() |
CompletableFuture<Void> |
whenComplete()
Returns a
CompletableFuture that completes when this stream is complete,
either successfully or exceptionally, including cancellation and abortion. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcloseFuture, completionFuture, drainAll, drainAll, isComplete, of, of, of, of, subscribe, subscribeprotected StreamMessageWrapper(StreamMessage<? extends T> delegate)
delegate.protected final StreamMessage<? extends T> delegate()
StreamMessage being decorated.public boolean isOpen()
StreamMessagetrue 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()
StreamMessagetrue 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 CompletableFuture<Void> whenComplete()
StreamMessageCompletableFuture 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.whenComplete in interface StreamMessage<T>public void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, io.netty.util.concurrent.EventExecutor executor)
StreamMessageSubscriber. 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 already.AbortedStreamException if this stream has been aborted.CancelledSubscriptionException if this stream has been
cancelled and SubscriptionOption.NOTIFY_CANCELLATION is
specified when subscribed.subscribe in interface StreamMessage<T>executor - the executor to subscribepublic void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, io.netty.util.concurrent.EventExecutor executor, SubscriptionOption... options)
StreamMessageSubscriber. 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 already.AbortedStreamException if this stream has been aborted.CancelledSubscriptionException if this stream has been
cancelled and SubscriptionOption.NOTIFY_CANCELLATION is
specified when subscribed.subscribe in interface StreamMessage<T>executor - the executor to subscribeoptions - SubscriptionOptions to subscribe withpublic CompletableFuture<List<T>> drainAll(io.netty.util.concurrent.EventExecutor executor)
StreamMessageStreamMessage and retrieves all elements from it.
The returned CompletableFuture may be completed exceptionally with the following exceptions:
IllegalStateException if other Subscriber subscribed to this stream already.AbortedStreamException if this stream has been aborted.drainAll in interface StreamMessage<T>executor - the executor to retrieve all elementsCompletableFuture which will be completed with the list of the elements retrieved.public CompletableFuture<List<T>> drainAll(io.netty.util.concurrent.EventExecutor executor, SubscriptionOption... options)
StreamMessageStreamMessage and retrieves all elements from it.
The returned CompletableFuture may be completed exceptionally with the following exceptions:
IllegalStateException if other Subscriber subscribed to this stream already.AbortedStreamException if this stream has been aborted.drainAll in interface StreamMessage<T>executor - the executor to retrieve all elementsoptions - SubscriptionOptions to subscribe with. Note that
SubscriptionOption.NOTIFY_CANCELLATION is ineffective because there's no
cancelling while draining all elements.CompletableFuture which will be completed with the list of the elements retrieved.public io.netty.util.concurrent.EventExecutor defaultSubscriberExecutor()
StreamMessageEventExecutor which will be used when a user subscribes using
StreamMessage.subscribe(Subscriber), StreamMessage.subscribe(Subscriber, SubscriptionOption...),
StreamMessage.drainAll() and StreamMessage.drainAll(SubscriptionOption...).
Please note that if this method is called multiple times, the returned EventExecutors can be
different depending on this StreamMessage implementation.
defaultSubscriberExecutor in interface StreamMessage<T>public void abort()
StreamMessageAbortedStreamException 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 void abort(Throwable cause)
StreamMessageThrowable 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.abort in interface StreamMessage<T>public StreamMessageDuplicator<T> toDuplicator()
StreamMessageStreamMessageDuplicator that duplicates this StreamMessage into one or
more StreamMessages, which publish the same elements.
Note that you cannot subscribe to this StreamMessage anymore after you call this method.
To subscribe, call StreamMessageDuplicator.duplicate() from the returned
StreamMessageDuplicator.toDuplicator in interface StreamMessage<T>public StreamMessageDuplicator<T> toDuplicator(io.netty.util.concurrent.EventExecutor executor)
StreamMessageStreamMessageDuplicator that duplicates this StreamMessage into one or
more StreamMessages, which publish the same elements.
Note that you cannot subscribe to this StreamMessage anymore after you call this method.
To subscribe, call StreamMessageDuplicator.duplicate() from the returned
StreamMessageDuplicator.toDuplicator in interface StreamMessage<T>executor - the executor to duplicateCopyright © 2020 LeanCloud. All rights reserved.