Package graphql.execution.reactive
Class CompletionStageSubscriber<U,D>
java.lang.Object
graphql.execution.reactive.CompletionStageSubscriber<U,D>
- Type Parameters:
U- published upstream elementsD- mapped downstream values
- All Implemented Interfaces:
org.reactivestreams.Subscriber<U>
- Direct Known Subclasses:
CompletionStageOrderedSubscriber
public class CompletionStageSubscriber<U,D>
extends Object
implements org.reactivestreams.Subscriber<U>
This subscriber can be used to map between a
Publisher of U
elements and map them into CompletionStage of D promises.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.reactivestreams.Subscriptionprotected final org.reactivestreams.Subscriber<? super D> protected final Queue<CompletionStage<?>> protected final AtomicBooleanprotected final LockKit.ReentrantLockprotected final Function<U, CompletionStage<D>> protected final AtomicReference<Runnable> -
Constructor Summary
ConstructorsConstructorDescriptionCompletionStageSubscriber(Function<U, CompletionStage<D>> mapper, org.reactivestreams.Subscriber<? super D> downstreamSubscriber) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinallyAfterEachPromiseFinishes(boolean isInFlightEmpty) org.reactivestreams.Subscriber<? super D> Get instance of downstream subscriberprotected voidhandleThrowableDuringMapping(Throwable throwable) protected booleanprotected booleanThe two terminal states are onComplete or onErrorprotected voidofferToInFlightQ(CompletionStage<?> completionStage) voidvoidvoidvoidonSubscribe(org.reactivestreams.Subscription subscription) protected voidwhenNextFinished(CompletionStage<D> completionStage, D d, Throwable throwable) This is called as each mappedCompletionStagecompletes with a value or exception
-
Field Details
-
mapper
-
downstreamSubscriber
-
delegatingSubscription
protected org.reactivestreams.Subscription delegatingSubscription -
inFlightDataQ
-
lock
-
onCompleteRun
-
isTerminal
-
-
Constructor Details
-
CompletionStageSubscriber
public CompletionStageSubscriber(Function<U, CompletionStage<D>> mapper, org.reactivestreams.Subscriber<? super D> downstreamSubscriber)
-
-
Method Details
-
getDownstreamSubscriber
Get instance of downstream subscriber- Returns:
Subscriber
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription) - Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<U>
-
onNext
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<U>
-
whenNextFinished
This is called as each mappedCompletionStagecompletes with a value or exception- Parameters:
completionStage- the completion stage that has completedd- the value completedthrowable- or the throwable that happened during completion
-
finallyAfterEachPromiseFinishes
protected void finallyAfterEachPromiseFinishes(boolean isInFlightEmpty) -
handleThrowableDuringMapping
-
onError
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<U>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<U>
-
offerToInFlightQ
-
inFlightQIsEmpty
protected boolean inFlightQIsEmpty() -
isTerminal
protected boolean isTerminal()The two terminal states are onComplete or onError- Returns:
- true if it's in a terminal state
-