Class GraphStageLogic.SubSourceOutlet<T>

java.lang.Object
org.apache.pekko.stream.stage.GraphStageLogic.SubSourceOutlet<T>
Enclosing class:
GraphStageLogic

public class GraphStageLogic.SubSourceOutlet<T> extends Object
INTERNAL API

This allows the dynamic creation of an Outlet for a GraphStage which is connected to a Source that is available for materialization (e.g. using the subFusingMaterializer). Completion, cancellation and failure of the parent operator is automatically delegated to instances of SubSourceOutlet to avoid resource leaks.

Even so it is good practice to use the timeout method to cancel this Outlet in case the corresponding Source is not materialized within a given time limit, see e.g. ActorMaterializerSettings.

To be thread safe this method must only be called from either the constructor of the graph operator during materialization or one of the methods invoked by the graph operator machinery, such as onPush and onPull.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Complete this output port.
    void
    Fail this output port.
    boolean
    Returns true if this output port can be pushed.
    boolean
    Returns true if this output port is closed, but caution THIS WORKS DIFFERENTLY THAN THE NORMAL isClosed(out).
    void
    push(T elem)
    Push to this output port.
    void
    Set OutHandler for this dynamic output port; this needs to be done before the first substream callback can arrive.
    Get the Source for this dynamic output port.
    void
    timeout(scala.concurrent.duration.FiniteDuration d)
    Set the source into timed-out mode if it has not yet been materialized.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SubSourceOutlet

      public SubSourceOutlet(String name)
  • Method Details

    • complete

      public void complete()
      Complete this output port.
    • fail

      public void fail(Throwable ex)
      Fail this output port.
    • isAvailable

      public boolean isAvailable()
      Returns true if this output port can be pushed.
    • isClosed

      public boolean isClosed()
      Returns true if this output port is closed, but caution THIS WORKS DIFFERENTLY THAN THE NORMAL isClosed(out). Due to possibly asynchronous shutdown it may not return true immediately after complete() or fail() have returned.
    • push

      public void push(T elem)
      Push to this output port.
    • setHandler

      public void setHandler(OutHandler handler)
      Set OutHandler for this dynamic output port; this needs to be done before the first substream callback can arrive.
    • source

      public Graph<SourceShape<T>,NotUsed> source()
      Get the Source for this dynamic output port.
    • timeout

      public void timeout(scala.concurrent.duration.FiniteDuration d)
      Set the source into timed-out mode if it has not yet been materialized.
    • toString

      public String toString()
      Overrides:
      toString in class Object