public abstract class StatefulStage<In,Out> extends PushPullStage<In,Out>
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(akka.stream.stage.StageState<In, Out>)
.
Use emit(scala.collection.Iterator<Out>, akka.stream.stage.Context<Out>)
or emitAndFinish(scala.collection.Iterator<Out>, akka.stream.stage.Context<Out>)
to push more than one element from StageState.onPush(In, akka.stream.stage.Context<Out>)
or
StageState.onPull(akka.stream.stage.Context<Out>)
.
Use terminationEmit(scala.collection.Iterator<Out>, akka.stream.stage.Context<Out>)
to push final elements from onUpstreamFinish(akka.stream.stage.Context<Out>)
or onUpstreamFailure(java.lang.Throwable, Ctx)
.
Modifier and Type | Class and Description |
---|---|
static interface |
StatefulStage.AndThen
Deprecated.
|
static class |
StatefulStage.Become
Deprecated.
|
static class |
StatefulStage.Become$
Deprecated.
|
static class |
StatefulStage.Finish$
Deprecated.
|
class |
StatefulStage.State
Deprecated.
Scala API
|
static class |
StatefulStage.Stay$
Deprecated.
|
AbstractStage.PushPullGraphStage<In,Out,Ext>, AbstractStage.PushPullGraphStageWithMaterializedValue<In,Out,Ext,Mat>
Constructor and Description |
---|
StatefulStage()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
become(StageState<In,Out> state)
Deprecated.
Change the behavior to another
StageState . |
StageState<In,Out> |
current()
Deprecated.
Current state.
|
static Supervision.Directive |
decide(java.lang.Throwable t)
Deprecated.
|
SyncDirective |
emit(scala.collection.Iterator<Out> iter,
Context<Out> ctx)
Deprecated.
Scala API: Can be used from
StageState.onPush(In, akka.stream.stage.Context<Out>) or StageState.onPull(akka.stream.stage.Context<Out>) to push more than one
element downstream. |
SyncDirective |
emit(java.util.Iterator<Out> iter,
Context<Out> ctx)
Deprecated.
Java API: Can be used from
StageState.onPush(In, akka.stream.stage.Context<Out>) or StageState.onPull(akka.stream.stage.Context<Out>) to push more than one
element downstream. |
SyncDirective |
emit(scala.collection.Iterator<Out> iter,
Context<Out> ctx,
StageState<In,Out> nextState)
Deprecated.
Scala API: Can be used from
StageState.onPush(In, akka.stream.stage.Context<Out>) or StageState.onPull(akka.stream.stage.Context<Out>) to push more than one
element downstream and after that change behavior. |
SyncDirective |
emit(java.util.Iterator<Out> iter,
Context<Out> ctx,
StageState<In,Out> nextState)
Deprecated.
Java API: Can be used from
StageState.onPush(In, akka.stream.stage.Context<Out>) or StageState.onPull(akka.stream.stage.Context<Out>) to push more than one
element downstream and after that change behavior. |
SyncDirective |
emitAndFinish(scala.collection.Iterator<Out> iter,
Context<Out> ctx)
Deprecated.
Scala API: Can be used from
StageState.onPush(In, akka.stream.stage.Context<Out>) or StageState.onPull(akka.stream.stage.Context<Out>) to push more than one
element downstream and after that finish (complete downstreams, cancel upstreams). |
SyncDirective |
emitAndFinish(java.util.Iterator<Out> iter,
Context<Out> ctx)
Deprecated.
Java API: Can be used from
StageState.onPush(In, akka.stream.stage.Context<Out>) or StageState.onPull(akka.stream.stage.Context<Out>) to push more than one
element downstream and after that finish (complete downstreams, cancel upstreams). |
abstract StageState<In,Out> |
initial()
Deprecated.
Concrete subclass must return the initial behavior from this method.
|
static boolean |
isDetached()
Deprecated.
|
static TerminationDirective |
onDownstreamFinish(Ctx ctx)
Deprecated.
|
SyncDirective |
onPull(Context<Out> ctx)
Deprecated.
Invokes current state.
|
SyncDirective |
onPush(In elem,
Context<Out> ctx)
Deprecated.
Invokes current state.
|
static TerminationDirective |
onUpstreamFailure(java.lang.Throwable cause,
Ctx ctx)
Deprecated.
|
TerminationDirective |
onUpstreamFinish(Context<Out> ctx)
Deprecated.
onUpstreamFinish is called when upstream has signaled that the stream is
successfully completed. |
static void |
postStop()
Deprecated.
|
static void |
preStart(LifeCtx ctx)
Deprecated.
|
static Stage<In,Out> |
restart()
Deprecated.
|
TerminationDirective |
terminationEmit(scala.collection.Iterator<Out> iter,
Context<Out> ctx)
Deprecated.
Scala API: Can be used from
onUpstreamFinish(akka.stream.stage.Context<Out>) to push final elements downstream
before completing the stream successfully. |
TerminationDirective |
terminationEmit(java.util.Iterator<Out> iter,
Context<Out> ctx)
Deprecated.
Java API: Can be used from
onUpstreamFinish(akka.stream.stage.Context<Out>) or onUpstreamFailure(java.lang.Throwable, Ctx) to push final
elements downstream. |
decide, isDetached, onDownstreamFinish, onUpstreamFailure, postStop, preStart, restart
public static boolean isDetached()
public static void preStart(LifeCtx ctx) throws java.lang.Exception
java.lang.Exception
public static TerminationDirective onDownstreamFinish(Ctx ctx)
public static TerminationDirective onUpstreamFailure(java.lang.Throwable cause, Ctx ctx)
public static void postStop() throws java.lang.Exception
java.lang.Exception
public static Supervision.Directive decide(java.lang.Throwable t)
public static Stage<In,Out> restart()
public abstract StageState<In,Out> initial()
**Warning:** This method must not be implemented as val
.
public final StageState<In,Out> current()
public final void become(StageState<In,Out> state)
StageState
.state
- (undocumented)public final SyncDirective onPush(In elem, Context<Out> ctx)
onPush
in class AbstractStage<In,Out,SyncDirective,SyncDirective,Context<Out>,LifecycleContext>
elem
- (undocumented)ctx
- (undocumented)public final SyncDirective onPull(Context<Out> ctx)
onPull
in class AbstractStage<In,Out,SyncDirective,SyncDirective,Context<Out>,LifecycleContext>
ctx
- (undocumented)public TerminationDirective onUpstreamFinish(Context<Out> ctx)
AbstractStage
onUpstreamFinish
is called when upstream has signaled that the stream is
successfully completed. Here you cannot call Context.push(Out)
,
because there might not be any demand from downstream. To emit additional elements before
terminating you can use Context.absorbTermination()
and push final elements
from AbstractStage.onPull(Ctx)
. The stage will then be in finishing state, which can be checked
with Context.isFinishing()
.
By default the finish signal is immediately propagated with 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”.
onUpstreamFinish
in class AbstractStage<In,Out,SyncDirective,SyncDirective,Context<Out>,LifecycleContext>
ctx
- (undocumented)public final SyncDirective emit(scala.collection.Iterator<Out> iter, Context<Out> ctx)
StageState.onPush(In, akka.stream.stage.Context<Out>)
or StageState.onPull(akka.stream.stage.Context<Out>)
to push more than one
element downstream.iter
- (undocumented)ctx
- (undocumented)public final SyncDirective emit(java.util.Iterator<Out> iter, Context<Out> ctx)
StageState.onPush(In, akka.stream.stage.Context<Out>)
or StageState.onPull(akka.stream.stage.Context<Out>)
to push more than one
element downstream.iter
- (undocumented)ctx
- (undocumented)public final SyncDirective emit(scala.collection.Iterator<Out> iter, Context<Out> ctx, StageState<In,Out> nextState)
StageState.onPush(In, akka.stream.stage.Context<Out>)
or StageState.onPull(akka.stream.stage.Context<Out>)
to push more than one
element downstream and after that change behavior.iter
- (undocumented)ctx
- (undocumented)nextState
- (undocumented)public final SyncDirective emit(java.util.Iterator<Out> iter, Context<Out> ctx, StageState<In,Out> nextState)
StageState.onPush(In, akka.stream.stage.Context<Out>)
or StageState.onPull(akka.stream.stage.Context<Out>)
to push more than one
element downstream and after that change behavior.iter
- (undocumented)ctx
- (undocumented)nextState
- (undocumented)public final SyncDirective emitAndFinish(scala.collection.Iterator<Out> iter, Context<Out> ctx)
StageState.onPush(In, akka.stream.stage.Context<Out>)
or StageState.onPull(akka.stream.stage.Context<Out>)
to push more than one
element downstream and after that finish (complete downstreams, cancel upstreams).iter
- (undocumented)ctx
- (undocumented)public final SyncDirective emitAndFinish(java.util.Iterator<Out> iter, Context<Out> ctx)
StageState.onPush(In, akka.stream.stage.Context<Out>)
or StageState.onPull(akka.stream.stage.Context<Out>)
to push more than one
element downstream and after that finish (complete downstreams, cancel upstreams).iter
- (undocumented)ctx
- (undocumented)public final TerminationDirective terminationEmit(scala.collection.Iterator<Out> iter, Context<Out> ctx)
onUpstreamFinish(akka.stream.stage.Context<Out>)
to push final elements downstream
before completing the stream successfully. Note that if this is used from
onUpstreamFailure(java.lang.Throwable, Ctx)
the failure will be absorbed and the stream will be completed
successfully.iter
- (undocumented)ctx
- (undocumented)public final TerminationDirective terminationEmit(java.util.Iterator<Out> iter, Context<Out> ctx)
onUpstreamFinish(akka.stream.stage.Context<Out>)
or onUpstreamFailure(java.lang.Throwable, Ctx)
to push final
elements downstream.iter
- (undocumented)ctx
- (undocumented)