Class CollectorStage<T>

java.lang.Object
org.apache.pekko.stream.stage.GraphStageWithMaterializedValue<org.apache.pekko.stream.SinkShape<T>,Collect<T>>
org.apache.pekko.http.impl.util.CollectorStage<T>
All Implemented Interfaces:
org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<T>,Collect<T>>

public class CollectorStage<T> extends org.apache.pekko.stream.stage.GraphStageWithMaterializedValue<org.apache.pekko.stream.SinkShape<T>,Collect<T>>
Stage similar to Sink.seq that provides a side-channel to get at the collection at any point. It will return all the collected elements and a flag whether the stream was completed or not.

When this is added to a fused flow it can be used to check what output and completion a given input will bring. Because the side-channel will go through the mailbox of the ActorGraphInterpreter the hope is that the fused stream will "run to exhaustion", i.e. it will run as far as it can, so that when the side-channel event is processed, no other (internal) events are still to be processed. This assumption does not hold if the source stream has asynchronous boundaries or components.

TODO: allow multiple rescheduling of AsyncCallback to make it more likely that all internal queues have been processed.

  • Constructor Details

    • CollectorStage

      public CollectorStage()
  • Method Details

    • resultAfterSourceElements

      public static <T, U> scala.concurrent.Future<scala.Tuple2<scala.collection.immutable.Seq<U>,Object>> resultAfterSourceElements(org.apache.pekko.stream.scaladsl.Source<T,Object> source, org.apache.pekko.stream.scaladsl.Flow<T,U,Object> flow, org.apache.pekko.stream.Materializer materializer)
    • Uninitialized

      public CollectorStage<T>.Uninitialized$ Uninitialized()
      Accessor for nested Scala object
      Returns:
      (undocumented)
    • Initialized

      public CollectorStage<T>.Initialized$ Initialized()
      Accessor for nested Scala object
      Returns:
      (undocumented)
    • in

      public org.apache.pekko.stream.Inlet<T> in()
    • shape

      public org.apache.pekko.stream.SinkShape<T> shape()
    • createLogicAndMaterializedValue

      public scala.Tuple2<org.apache.pekko.stream.stage.GraphStageLogic,Collect<T>> createLogicAndMaterializedValue(org.apache.pekko.stream.Attributes inheritedAttributes)
      Specified by:
      createLogicAndMaterializedValue in class org.apache.pekko.stream.stage.GraphStageWithMaterializedValue<org.apache.pekko.stream.SinkShape<T>,Collect<T>>