T - the type of elements@UnstableApi public class DefaultStreamMessageDuplicator<T> extends Object implements StreamMessageDuplicator<T>
StreamMessageDuplicator| Constructor and Description |
|---|
DefaultStreamMessageDuplicator(StreamMessage<T> upstream,
SignalLengthGetter<? super T> signalLengthGetter,
io.netty.util.concurrent.EventExecutor executor,
long maxSignalLength)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Closes this duplicator and aborts all stream messages returned by
StreamMessageDuplicator.duplicate(). |
void |
abort(Throwable cause)
Closes this duplicator and aborts all stream messages returned by
StreamMessageDuplicator.duplicate()
with the specified Throwable. |
void |
close()
Closes this duplicator and prevents it from further duplication.
|
StreamMessage<T> |
duplicate()
Returns a new
StreamMessage that publishes the same elements as the StreamMessage
that this duplicator is created from. |
protected io.netty.util.concurrent.EventExecutor |
duplicatorExecutor()
Returns the default
EventExecutor which will be used when a user subscribes to a child
stream using StreamMessage.subscribe(Subscriber, SubscriptionOption...). |
public DefaultStreamMessageDuplicator(StreamMessage<T> upstream, SignalLengthGetter<? super T> signalLengthGetter, io.netty.util.concurrent.EventExecutor executor, long maxSignalLength)
public StreamMessage<T> duplicate()
StreamMessageDuplicatorStreamMessage that publishes the same elements as the StreamMessage
that this duplicator is created from.duplicate in interface StreamMessageDuplicator<T>protected io.netty.util.concurrent.EventExecutor duplicatorExecutor()
EventExecutor which will be used when a user subscribes to a child
stream using StreamMessage.subscribe(Subscriber, SubscriptionOption...).public void close()
StreamMessageDuplicatorStreamMessageDuplicator.duplicate() will raise
an IllegalStateException after this method is invoked.
Note that the previously duplicated streams will not be closed but will
continue publishing data until the original StreamMessage is closed.
All the data published from the original StreamMessage are cleaned up when
all duplicated streams are complete. If you want to stop publishing and clean
up the resources immediately, call StreamMessageDuplicator.abort().
close in interface StreamMessageDuplicator<T>close in interface SafeCloseableclose in interface AutoCloseablepublic void abort()
StreamMessageDuplicatorStreamMessageDuplicator.duplicate().
This will also clean up the data published from the original StreamMessage.abort in interface StreamMessageDuplicator<T>public void abort(Throwable cause)
StreamMessageDuplicatorStreamMessageDuplicator.duplicate()
with the specified Throwable.
This will also clean up the data published from the original StreamMessage.abort in interface StreamMessageDuplicator<T>Copyright © 2020 LeanCloud. All rights reserved.