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.Subscription
protected final org.reactivestreams.Subscriber
<? super D> protected final Queue
<CompletionStage<?>> protected final AtomicBoolean
protected final LockKit.ReentrantLock
protected 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 void
finallyAfterEachPromiseFinishes
(boolean isInFlightEmpty) org.reactivestreams.Subscriber
<? super D> Get instance of downstream subscriberprotected void
handleThrowableDuringMapping
(Throwable throwable) protected boolean
protected boolean
The two terminal states are onComplete or onErrorprotected void
offerToInFlightQ
(CompletionStage<?> completionStage) void
void
void
void
onSubscribe
(org.reactivestreams.Subscription subscription) protected void
whenNextFinished
(CompletionStage<D> completionStage, D d, Throwable throwable) This is called as each mappedCompletionStage
completes 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:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<U>
-
onNext
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<U>
-
whenNextFinished
This is called as each mappedCompletionStage
completes 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:
onError
in interfaceorg.reactivestreams.Subscriber<U>
-
onComplete
public void onComplete()- Specified by:
onComplete
in 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
-