Class CompletionStageSubscriber<U,D>

java.lang.Object
graphql.execution.reactive.CompletionStageSubscriber<U,D>
Type Parameters:
U - published upstream elements
D - 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 Details

  • Constructor Details

    • CompletionStageSubscriber

      public CompletionStageSubscriber(Function<U,CompletionStage<D>> mapper, org.reactivestreams.Subscriber<? super D> downstreamSubscriber)
  • Method Details

    • getDownstreamSubscriber

      public org.reactivestreams.Subscriber<? super D> getDownstreamSubscriber()
      Get instance of downstream subscriber
      Returns:
      Subscriber
    • onSubscribe

      public void onSubscribe(org.reactivestreams.Subscription subscription)
      Specified by:
      onSubscribe in interface org.reactivestreams.Subscriber<U>
    • onNext

      public void onNext(U u)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<U>
    • whenNextFinished

      protected void whenNextFinished(CompletionStage<D> completionStage, D d, Throwable throwable)
      This is called as each mapped CompletionStage completes with a value or exception
      Parameters:
      completionStage - the completion stage that has completed
      d - the value completed
      throwable - or the throwable that happened during completion
    • finallyAfterEachPromiseFinishes

      protected void finallyAfterEachPromiseFinishes(boolean isInFlightEmpty)
    • handleThrowableDuringMapping

      protected void handleThrowableDuringMapping(Throwable throwable)
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface org.reactivestreams.Subscriber<U>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface org.reactivestreams.Subscriber<U>
    • offerToInFlightQ

      protected void offerToInFlightQ(CompletionStage<?> completionStage)
    • 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