- java.lang.Object
-
- io.helidon.common.reactive.BufferedProcessor<T,U>
-
- Type Parameters:
T- subscribed type (input)U- published type (output)
- All Implemented Interfaces:
Flow.Processor<T,U>,Flow.Publisher<U>,Flow.Subscriber<T>,Flow.Subscription
- Direct Known Subclasses:
MultiDistinctProcessor,MultiDropWhileProcessor,MultiFilterProcessor,MultiLimitProcessor,MultiMapProcessor,MultiOnErrorResumeProcessor,MultiPeekProcessor,MultiSkipProcessor,MultiTakeWhileProcessor,MultiTappedProcessor
public abstract class BufferedProcessor<T,U> extends Object
Processor with back-pressure buffer.
-
-
Constructor Summary
Constructors Constructor Description BufferedProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()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(T item)Hook forFlow.Subscriber.onNext(java.lang.Object).protected voidnotEnoughRequest(U item)Define what to do when there is not enough requests to submit item.voidonComplete()voidonError(Throwable ex)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.protected voidtryRequest(Flow.Subscription subscription)Responsible for callingFlow.Subscription.request(long).
-
-
-
Method Detail
-
tryRequest
protected void tryRequest(Flow.Subscription subscription)
Responsible for callingFlow.Subscription.request(long).- Parameters:
subscription-Flow.Subscriptionto make a request from
-
notEnoughRequest
protected void notEnoughRequest(U item)
Define what to do when there is not enough requests to submit item.- Parameters:
item- Item for submitting
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceFlow.Subscriber<T>
-
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
-
hookOnNext
protected void hookOnNext(T 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
-
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.
-
-