Class DefaultStreamMessageDuplicator<T>
java.lang.Object
com.linecorp.armeria.common.stream.DefaultStreamMessageDuplicator<T>
- Type Parameters:
T
- the type of elements
- All Implemented Interfaces:
StreamMessageDuplicator<T>
,SafeCloseable
,AutoCloseable
@UnstableApi
public class DefaultStreamMessageDuplicator<T>
extends Object
implements StreamMessageDuplicator<T>
A default duplicator.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultStreamMessageDuplicator
(StreamMessage<T> upstream, SignalLengthGetter<? super T> signalLengthGetter, EventExecutor executor, long maxSignalLength) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
abort()
Closes this duplicator and aborts all stream messages returned byStreamMessageDuplicator.duplicate()
.final void
Closes this duplicator and aborts all stream messages returned byStreamMessageDuplicator.duplicate()
with the specifiedThrowable
.final void
close()
Closes this duplicator and prevents it from further duplication.Returns a newStreamMessage
that publishes the same elements as theStreamMessage
that this duplicator is created from.protected final EventExecutor
Returns the defaultEventExecutor
which will be used when a user subscribes to a child stream usingStreamMessage.subscribe(Subscriber, SubscriptionOption...)
.
-
Constructor Details
-
DefaultStreamMessageDuplicator
public DefaultStreamMessageDuplicator(StreamMessage<T> upstream, SignalLengthGetter<? super T> signalLengthGetter, EventExecutor executor, long maxSignalLength) Creates a new instance.
-
-
Method Details
-
duplicate
Description copied from interface:StreamMessageDuplicator
Returns a newStreamMessage
that publishes the same elements as theStreamMessage
that this duplicator is created from.- Specified by:
duplicate
in interfaceStreamMessageDuplicator<T>
-
duplicatorExecutor
Returns the defaultEventExecutor
which will be used when a user subscribes to a child stream usingStreamMessage.subscribe(Subscriber, SubscriptionOption...)
. -
close
public final void close()Description copied from interface:StreamMessageDuplicator
Closes this duplicator and prevents it from further duplication.StreamMessageDuplicator.duplicate()
will raise anIllegalStateException
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 originalStreamMessage
are cleaned up when all duplicated streams are complete. If you want to stop publishing and clean up the resources immediately, callStreamMessageDuplicator.abort()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSafeCloseable
- Specified by:
close
in interfaceStreamMessageDuplicator<T>
-
abort
public final void abort()Description copied from interface:StreamMessageDuplicator
Closes this duplicator and aborts all stream messages returned byStreamMessageDuplicator.duplicate()
. This will also clean up the data published from the originalStreamMessage
.- Specified by:
abort
in interfaceStreamMessageDuplicator<T>
-
abort
Description copied from interface:StreamMessageDuplicator
Closes this duplicator and aborts all stream messages returned byStreamMessageDuplicator.duplicate()
with the specifiedThrowable
. This will also clean up the data published from the originalStreamMessage
.- Specified by:
abort
in interfaceStreamMessageDuplicator<T>
-