package stage
- Alphabetic
- Public
- All
Type Members
-
abstract
class
AbstractInHandler
extends InHandler
Java API: callbacks for an input port where termination logic is predefined (completing when upstream completes, failing when upstream fails).
-
abstract
class
AbstractInOutHandler
extends InHandler with OutHandler
Java API: callback combination for output and input ports where termination logic is predefined (completing when upstream completes, failing when upstream fails, completing when downstream cancels).
-
abstract
class
AbstractOutHandler
extends OutHandler
Java API: callbacks for an output port where termination logic is predefined (completing when downstream cancels).
-
trait
AsyncCallback
[T] extends AnyRef
An asynchronous callback holder that is attached to a GraphStageLogic.
An asynchronous callback holder that is attached to a GraphStageLogic. Invoking AsyncCallback#invoke will eventually lead to the registered handler being called.
- sealed trait AsyncDirective extends Directive
-
sealed
trait
Context
[Out] extends LifecycleContext
Passed to the callback methods of PushPullStage and StatefulStage.
-
trait
DetachedContext
[Out] extends Context[Out]
Passed to the callback methods of DetachedStage.
Passed to the callback methods of DetachedStage.
#hold stops execution and at the same time putting the stage in a holding 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 #pushAndPull which results in two events making the balance right again: 1 hold + 1 external event = 2 external event
-
sealed
trait
Directive
extends AnyRef
Return type from Context methods.
- sealed trait DownstreamDirective extends SyncDirective
- sealed abstract class FreeDirective extends UpstreamDirective with DownstreamDirective with TerminationDirective with AsyncDirective
-
abstract
class
GraphStage
[S <: Shape] extends GraphStageWithMaterializedValue[S, NotUsed]
A GraphStage represents a reusable graph stream processing stage.
A GraphStage represents a reusable graph stream processing stage. A GraphStage consists of a Shape which describes its input and output ports and a factory function that creates a GraphStageLogic which implements the processing logic that ties the ports together.
-
abstract
class
GraphStageLogic
extends AnyRef
Represents the processing logic behind a GraphStage.
Represents the processing logic behind a GraphStage. Roughly speaking, a subclass of GraphStageLogic is a collection of the following parts: * A set of InHandler and OutHandler instances and their assignments to the Inlets and Outlets of the enclosing GraphStage * Possible mutable state, accessible from the InHandler and OutHandler callbacks, but not from anywhere else (as such access would not be thread-safe) * The lifecycle hooks preStart() and postStop() * Methods for performing stream processing actions, like pulling or pushing elements
The stage logic is completed once all its input and output ports have been closed. This can be changed by setting
setKeepGoing
to true.The
postStop
lifecycle hook on the logic itself is called once all ports are closed. This is the only tear down callback that is guaranteed to happen, if the actor system or the materializer is terminated the handlers may never see any callbacks toonUpstreamFailure
,onUpstreamFinish
oronDownstreamFinish
. Therefore stage resource cleanup should always be done inpostStop
. -
abstract
class
GraphStageLogicWithLogging
extends GraphStageLogic with StageLogging
Java API: GraphStageLogic with StageLogging.
- abstract class GraphStageWithMaterializedValue [+S <: Shape, +M] extends Graph[S, M]
-
trait
InHandler
extends AnyRef
Collection of callbacks for an input port of a GraphStage
- trait LifecycleContext extends AnyRef
-
trait
OutHandler
extends AnyRef
Collection of callbacks for an output port of a GraphStage
-
trait
StageLogging
extends AnyRef
Simple way to obtain a LoggingAdapter when used together with an ActorMaterializer.
Simple way to obtain a LoggingAdapter when used together with an ActorMaterializer. If used with a different materializer NoLogging will be returned.
Make sure to only access
log
from GraphStage callbacks (such aspull
,push
or the async-callback).Note, abiding to akka.stream.ActorAttributes.logLevels has to be done manually, the logger itself is configured based on the logSource provided to it. Also, the
log
itself would not know if you're calling it from a "on element" context or not, which is why these decisions have to be handled by the stage itself. -
abstract
class
StageState
[In, Out] extends AnyRef
The behavior of StatefulStage is defined by these two methods, which has the same semantics as corresponding methods in PushPullStage.
- sealed trait SyncDirective extends Directive
- sealed trait TerminationDirective extends SyncDirective
- abstract class TimerGraphStageLogic extends GraphStageLogic
-
abstract
class
TimerGraphStageLogicWithLogging
extends TimerGraphStageLogic with StageLogging
Java API: TimerGraphStageLogic with StageLogging.
- sealed trait UpstreamDirective extends SyncDirective
-
abstract
class
AbstractStage
[-In, Out, PushD <: Directive, PullD <: Directive, Ctx <: Context[Out], LifeCtx <: LifecycleContext] extends Stage[In, Out]
- Annotations
- @deprecated
- Deprecated
(Since version 2.4.2) Please use GraphStage instead.
-
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
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 aDetachedStage
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.
- See also
-
abstract
class
PushPullStage
[In, Out] extends AbstractStage[In, Out, SyncDirective, SyncDirective, Context[Out], LifecycleContext]
PushPullStage
implementations participate in 1-bounded regions.PushPullStage
implementations participate in 1-bounded regions. For every external non-completion signal these stages produce *exactly one* push or pull signal.#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 Context#push to emit one element downstream, or you can absorb the element by calling Context#pull. Note that you can only emit zero or one element downstream fromonPull
. To emit more than one element you have to push the remaining elements from #onPull, one-by-one.onPush
is not called again untilonPull
has requested more elements with Context#pull.StatefulStage has support for making it easy to emit more than one element from
onPush
.#onPull is called when there is demand from downstream, i.e. you are allowed to push one element downstream with Context#push, or request elements from upstreams with Context#pull. If you always perform transitive pull by calling
ctx.pull
fromonPull
you can use PushStage instead ofPushPullStage
.Stages are allowed to do early completion of downstream and cancel of upstream. This is done with Context#finish, which is a combination of cancel/complete.
Since onComplete is not a backpressured signal it is sometimes preferable to push a final element and then immediately finish. This combination is exposed as Context#pushAndFinish which enables stages to propagate completion events without waiting for an extra round of pull.
Another peculiarity is how to convert termination events (complete/failure) into elements. The problem here is that the termination events are not backpressured while elements are. This means that simply calling Context#push as a response to #onUpstreamFinish or #onUpstreamFailure will very likely break boundedness and result in a buffer overflow somewhere. Therefore the only allowed command in this case is Context#absorbTermination which stops the propagation of the termination signal, and puts the stage in a akka.stream.stage.Context#isFinishing state. Depending on whether the stage has a pending pull signal it has not yet "consumed" by a push its #onPull handler might be called immediately or later. From #onPull final elements can be pushed before completing downstream with Context#finish or Context#pushAndFinish.
StatefulStage has support for making it easy to emit final elements.
All these rules are enforced by types and runtime checks where needed. Always return the
Directive
from the call to the Context method, and do only call Context commands once per callback.- Annotations
- @deprecated
- Deprecated
(Since version 2.4.2) Please use GraphStage instead.
- See also
-
abstract
class
PushStage
[In, Out] extends PushPullStage[In, Out]
PushStage
is a PushPullStage that always perform transitive pull by callingctx.pull
fromonPull
.PushStage
is a PushPullStage that always perform transitive pull by callingctx.pull
fromonPull
.- Annotations
- @deprecated
- Deprecated
(Since version 2.4.2) Please use GraphStage instead.
-
sealed
trait
Stage
[-In, +Out] extends AnyRef
General interface for stream transformation.
General interface for stream transformation.
Custom
Stage
implementations are intended to be used with akka.stream.scaladsl.FlowOps#transform or akka.stream.javadsl.Flow#transform to extend theFlow
API when there is no specialized operator that performs the transformation.Custom implementations are subclasses of PushPullStage or DetachedStage. Sometimes it is convenient to extend StatefulStage for support of become like behavior.
It is possible to keep state in the concrete
Stage
instance with ordinary instance variables. TheTransformer
is executed by an actor and therefore you do not have to add any additional thread safety or memory visibility constructs to access the state from the callback methods.- Annotations
- @deprecated
- Deprecated
(Since version 2.4.2) Please use GraphStage instead.
- See also
-
abstract
class
StatefulStage
[In, Out] extends PushPullStage[In, Out]
StatefulStage
is a PushPullStage that provides convenience to make some things easier.StatefulStage
is a PushPullStage that provides convenience to make some things easier.The behavior is defined in StageState instances. The initial behavior is specified by subclass implementing the #initial method. The behavior can be changed by using #become.
Use #emit or #emitAndFinish to push more than one element from StageState#onPush or StageState#onPull.
Use #terminationEmit to push final elements from #onUpstreamFinish or #onUpstreamFailure.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0-M2) StatefulStage is deprecated, please use GraphStage instead.
Value Members
-
object
AbstractStage
INTERNAL API
- object GraphStageLogic