c

akka.stream.stage

DetachedStage

abstract class DetachedStage[In, Out] extends AbstractStage[In, Out, UpstreamDirective, DownstreamDirective, DetachedContext[Out], LifecycleContext]

DetachedStage can be used to implement operations similar to buffer, expand and conflate.

DetachedStage implementations are boundaries between 1-bounded regions. This means that they need to enforce the "exactly one" property both on their upstream and downstream regions. As a consequence a DetachedStage can never answer an #onPull with a Context#pull or answer an #onPush with a Context#push since such an action would "steal" the event from one region (resulting in zero signals) and would inject it to the other region (resulting in two signals).

However, DetachedStages have the ability to call akka.stream.stage.DetachedContext#hold as a response to #onPush and #onPull which temporarily takes the signal off and stops execution, at the same time putting the stage in an akka.stream.stage.DetachedContext#isHolding state. If the stage is in a holding state it contains one absorbed signal, therefore in this state the only possible command to call is akka.stream.stage.DetachedContext#pushAndPull which results in two events making the balance right again: 1 hold + 1 external event = 2 external event

This mechanism allows synchronization between the upstream and downstream regions which otherwise can progress independently.

Annotations
@deprecated
Deprecated

(Since version 2.4.2) Please use GraphStage instead.

Source
Stage.scala
See also

PushPullStage

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DetachedStage
  2. AbstractStage
  3. Stage
  4. AnyRef
  5. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new DetachedStage()

Abstract Value Members

  1. abstract def onPull(ctx: DetachedContext[Out]): DownstreamDirective

    onPull is called when there is demand from downstream, i.e.

    onPull is called when there is demand from downstream, i.e. you are allowed to push one element downstream with akka.stream.stage.Context#push, or request elements from upstreams with akka.stream.stage.Context#pull

    Definition Classes
    AbstractStage
  2. abstract def onPush(elem: In, ctx: DetachedContext[Out]): UpstreamDirective

    onPush is called when an element from upstream is available and there is demand from downstream, i.e.

    onPush is called when an element from upstream is available and there is demand from downstream, i.e. in onPush you are allowed to call akka.stream.stage.Context#push to emit one element downstream, or you can absorb the element by calling akka.stream.stage.Context#pull. Note that you can only emit zero or one element downstream from onPull.

    To emit more than one element you have to push the remaining elements from #onPull, one-by-one. onPush is not called again until onPull has requested more elements with akka.stream.stage.Context#pull.

    Definition Classes
    AbstractStage

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to any2stringadd[DetachedStage[In, Out]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (DetachedStage[In, Out], B)
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to ArrowAssoc[DetachedStage[In, Out]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def decide(t: Throwable): Supervision.Directive

    If an exception is thrown from #onPush this method is invoked to decide how to handle the exception.

    If an exception is thrown from #onPush this method is invoked to decide how to handle the exception. By default this method returns Supervision.Stop.

    If an exception is thrown from #onPull or if the stage is holding state the stream will always be completed with failure, because it is not always possible to recover from that state. In concrete stages it is of course possible to use ordinary try-catch-recover inside onPull when it is know how to recover from such exceptions.

    Definition Classes
    DetachedStageAbstractStage
  9. def ensuring(cond: (DetachedStage[In, Out]) ⇒ Boolean, msg: ⇒ Any): DetachedStage[In, Out]
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to Ensuring[DetachedStage[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: (DetachedStage[In, Out]) ⇒ Boolean): DetachedStage[In, Out]
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to Ensuring[DetachedStage[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean, msg: ⇒ Any): DetachedStage[In, Out]
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to Ensuring[DetachedStage[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean): DetachedStage[In, Out]
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to Ensuring[DetachedStage[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to StringFormat[DetachedStage[In, Out]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  17. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  23. def onDownstreamFinish(ctx: DetachedContext[Out]): TerminationDirective

    onDownstreamFinish is called when downstream has canceled.

    onDownstreamFinish is called when downstream has canceled.

    By default the cancel signal is immediately propagated with akka.stream.stage.Context#finish.

    Definition Classes
    AbstractStage
  24. def onUpstreamFailure(cause: Throwable, ctx: DetachedContext[Out]): TerminationDirective

    onUpstreamFailure is called when upstream has signaled that the stream is completed with failure.

    onUpstreamFailure is called when upstream has signaled that the stream is completed with failure. It is not called if #onPull or #onPush of the stage itself throws an exception.

    Note that elements that were emitted by upstream before the failure happened might not have been received by this stage when onUpstreamFailure is called, i.e. failures are not backpressured and might be propagated as soon as possible.

    Here you cannot call akka.stream.stage.Context#push, because there might not be any demand from downstream. To emit additional elements before terminating you can use akka.stream.stage.Context#absorbTermination and push final elements from #onPull. The stage will then be in finishing state, which can be checked with akka.stream.stage.Context#isFinishing.

    Definition Classes
    AbstractStage
  25. def onUpstreamFinish(ctx: DetachedContext[Out]): TerminationDirective

    onUpstreamFinish is called when upstream has signaled that the stream is successfully completed.

    onUpstreamFinish is called when upstream has signaled that the stream is successfully completed. Here you cannot call akka.stream.stage.Context#push, because there might not be any demand from downstream. To emit additional elements before terminating you can use akka.stream.stage.Context#absorbTermination and push final elements from #onPull. The stage will then be in finishing state, which can be checked with akka.stream.stage.Context#isFinishing.

    By default the finish signal is immediately propagated with akka.stream.stage.Context#finish.

    *IMPORTANT NOTICE:* this signal is not back-pressured, it might arrive from upstream even though the last action by this stage was a “push”.

    Definition Classes
    AbstractStage
  26. def postStop(): Unit

    User overridable callback.

    User overridable callback.

    Is called after the Stages final action is performed. // TODO need better wording here Empty default implementation.

    Definition Classes
    AbstractStage
    Annotations
    @throws( classOf[Exception] )
  27. def preStart(ctx: LifecycleContext): Unit

    User overridable callback.

    User overridable callback.

    It is called before any other method defined on the Stage. Empty default implementation.

    Definition Classes
    AbstractStage
    Annotations
    @throws( classOf[Exception] )
  28. def restart(): Stage[In, Out]

    Used to create a fresh instance of the stage after an error resulting in a Supervision.Restart directive.

    Used to create a fresh instance of the stage after an error resulting in a Supervision.Restart directive. By default it will return the same instance untouched, so you must override it if there are any state that should be cleared before restarting, e.g. by returning a new instance.

    Definition Classes
    AbstractStage
  29. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def [B](y: B): (DetachedStage[In, Out], B)
    Implicit
    This member is added by an implicit conversion from DetachedStage[In, Out] to ArrowAssoc[DetachedStage[In, Out]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Stage[In, Out]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from DetachedStage[In, Out] to any2stringadd[DetachedStage[In, Out]]

Inherited by implicit conversion StringFormat from DetachedStage[In, Out] to StringFormat[DetachedStage[In, Out]]

Inherited by implicit conversion Ensuring from DetachedStage[In, Out] to Ensuring[DetachedStage[In, Out]]

Inherited by implicit conversion ArrowAssoc from DetachedStage[In, Out] to ArrowAssoc[DetachedStage[In, Out]]

Ungrouped