- java.lang.Object
-
- io.helidon.common.reactive.BufferedProcessor<R,R>
-
- io.helidon.common.reactive.MultiTappedProcessor<R>
-
- Type Parameters:
R- Type of the processed items.
- All Implemented Interfaces:
Multi<R>,Subscribable<R>,Flow.Processor<R,R>,Flow.Publisher<R>,Flow.Subscriber<R>,Flow.Subscription
public class MultiTappedProcessor<R> extends BufferedProcessor<R,R> implements Multi<R>
Processor executing provided functions on passing signals onNext, onError, onComplete, onCancel.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()static <R> MultiTappedProcessor<R>create()Create new processor with no functions to execute when signals are intercepted.protected voiddoSubscribe(Flow.Publisher<U> delegate)Subscribe the subscriber after the given delegate publisher.protected voidfail(Throwable ex)OnError downstream.protected voidfailAndCancel(Throwable ex)OnError downstream and cancel upstream.protected RequestedCountergetRequestedCounter()ReturnsRequestedCounterwith information about requested vs.protected SingleSubscriberHolder<U>getSubscriber()Processor'sSingleSubscriberHolder.protected Optional<Flow.Subscription>getSubscription()Processor'sFlow.Subscriptionregistered byFlow.Subscriber.onSubscribe(Flow.Subscription).protected voidhookOnCancel(Flow.Subscription subscription)Hook forSingleSubscriberHolder.cancel().protected voidhookOnComplete()Hook forFlow.Subscriber.onComplete().protected voidhookOnError(Throwable error)protected voidhookOnNext(R item)Hook forFlow.Subscriber.onNext(java.lang.Object).MultiTappedProcessor<R>onCancel(Consumer<Flow.Subscription> consumer)Set consumer to be executed when onCancel signal is intercepted.MultiTappedProcessor<R>onComplete(Runnable runnable)SetRunnableto be executed when onComplete signal is intercepted.voidonError(Throwable ex)MultiTappedProcessor<R>onError(Consumer<Throwable> consumer)SetConsumerto be executed when onError signal is intercepted.MultiTappedProcessor<R>onNext(Function<R,R> function)SetFunctionto be executed when onNext signal is intercepted.voidonNext(T item)voidonSubscribe(Flow.Subscription s)voidrequest(long n)protected voidsubmit(U item)Submit an item to the subscriber.voidsubscribe(Flow.Subscriber<? super U> s)protected voidtryComplete()Try close processor's subscriber.-
Methods inherited from class io.helidon.common.reactive.BufferedProcessor
notEnoughRequest, onComplete, tryRequest
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
-
Methods inherited from interface io.helidon.common.reactive.Multi
collect, collectList, distinct, dropWhile, filter, first, flatMap, flatMapIterable, forEach, limit, map, peek, skip, takeWhile
-
Methods inherited from interface io.helidon.common.reactive.Subscribable
onErrorResume, onErrorResumeWith, onTerminate, subscribe, subscribe, subscribe, subscribe
-
-
-
-
Method Detail
-
create
public static <R> MultiTappedProcessor<R> create()
Create new processor with no functions to execute when signals are intercepted.- Type Parameters:
R- Type of the processed items.- Returns:
- Brand new
MultiTappedProcessor
-
onNext
public MultiTappedProcessor<R> onNext(Function<R,R> function)
SetFunctionto be executed when onNext signal is intercepted.- Parameters:
function- Function to be invoked.- Returns:
- This
MultiTappedProcessor
-
onError
public MultiTappedProcessor<R> onError(Consumer<Throwable> consumer)
SetConsumerto be executed when onError signal is intercepted.- Specified by:
onErrorin interfaceSubscribable<R>- Parameters:
consumer- Consumer to be executed when onError signal is intercepted, argument is interceptedThrowable.- Returns:
- This
MultiTappedProcessor
-
onComplete
public MultiTappedProcessor<R> onComplete(Runnable runnable)
SetRunnableto be executed when onComplete signal is intercepted.- Specified by:
onCompletein interfaceSubscribable<R>- Parameters:
runnable-Runnableto be executed.- Returns:
- This
MultiTappedProcessor
-
onCancel
public MultiTappedProcessor<R> onCancel(Consumer<Flow.Subscription> consumer)
Set consumer to be executed when onCancel signal is intercepted.- Parameters:
consumer- Consumer to be executed when onCancel signal is intercepted, argument is interceptedFlow.Subscription.- Returns:
- This
MultiTappedProcessor
-
hookOnNext
protected void hookOnNext(R item)
Hook forFlow.Subscriber.onNext(java.lang.Object).- Parameters:
item- next item
-
hookOnError
protected void hookOnError(Throwable error)
- Parameters:
error- error received
-
hookOnComplete
protected void hookOnComplete()
Hook forFlow.Subscriber.onComplete().
-
hookOnCancel
protected void hookOnCancel(Flow.Subscription subscription)
Hook forSingleSubscriberHolder.cancel().- Parameters:
subscription- of the processor for optional passing cancel event
-
request
public void request(long n)
- Specified by:
requestin interfaceFlow.Subscription
-
cancel
public void cancel()
- Specified by:
cancelin interfaceFlow.Subscription
-
onSubscribe
public void onSubscribe(Flow.Subscription s)
- Specified by:
onSubscribein interfaceFlow.Subscriber<T>
-
onNext
public void onNext(T item)
- Specified by:
onNextin interfaceFlow.Subscriber<T>
-
fail
protected void fail(Throwable ex)
OnError downstream.- Parameters:
ex- Exception to be reported downstream
-
failAndCancel
protected void failAndCancel(Throwable ex)
OnError downstream and cancel upstream.- Parameters:
ex- Exception to be reported downstream
-
onError
public void onError(Throwable ex)
- Specified by:
onErrorin interfaceFlow.Subscriber<T>
-
subscribe
public void subscribe(Flow.Subscriber<? super U> s)
- Specified by:
subscribein interfaceFlow.Publisher<T>
-
getSubscription
protected Optional<Flow.Subscription> getSubscription()
Processor'sFlow.Subscriptionregistered byFlow.Subscriber.onSubscribe(Flow.Subscription).- Returns:
Flow.Subscription
-
getSubscriber
protected SingleSubscriberHolder<U> getSubscriber()
Processor'sSingleSubscriberHolder.- Returns:
SingleSubscriberHolder
-
getRequestedCounter
protected RequestedCounter getRequestedCounter()
ReturnsRequestedCounterwith information about requested vs. submitted items.- Returns:
RequestedCounter
-
submit
protected void submit(U item)
Submit an item to the subscriber.- Parameters:
item- item to be submitted
-
doSubscribe
protected final void doSubscribe(Flow.Publisher<U> delegate)
Subscribe the subscriber after the given delegate publisher.- Parameters:
delegate- delegate publisher
-
tryComplete
protected void tryComplete()
Try close processor's subscriber.
-
-