Namespace Akka.Streams.Stage
Classes
AbstractStage<TIn, TOut>
TBD
AbstractStage<TIn, TOut, TPushDirective, TPullDirective, TContext>
TBD
ConditionalTerminateInput
Input handler that terminates the state upon receiving completion if the given condition holds at that time.The stage fails upon receiving a failure.
ConditionalTerminateOutput
Output handler that terminates the state upon receiving completion if the given condition holds at that time.The stage fails upon receiving a failure.
DetachedStage<TIn, TOut>
DetachedStage can be used to implement operations similar to Buffer<TIn, TOut, TMat>(Flow<TIn, TOut, TMat>, Int32, OverflowStrategy), Expand<TIn, TOut1, TOut2, TMat>(Flow<TIn, TOut1, TMat>, Func<TOut1, IEnumerator<TOut2>>) and Conflate<TIn, TOut, TMat>(Flow<TIn, TOut, TMat>, Func<TOut, TOut, TOut>).
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(IContext) with a Pull() or answer an OnPush(TIn, IContext) with a Push(Object) 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 HoldUpstream() and HoldDownstream() as a response to OnPush(TIn, IContext) and OnPull(IContext) which temporarily takes the signal off and stops execution, at the same time putting the stage in an IsHoldingBoth 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(Object) 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.
EagerTerminateInput
Input handler that terminates the stage upon receiving completion. The stage fails upon receiving a failure.
EagerTerminateOutput
Output handler that terminates the stage upon cancellation.
FreeDirective
TBD
GraphStage<TShape>
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.
GraphStageLogic
Represents the processing logic behind a GraphStage<TShape>. 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<TShape>
* 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(Boolean) 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 to OnUpstreamFailure(Exception), OnUpstreamFinish() or OnDownstreamFinish(Exception). Therefore stage resource cleanup should always be done in PostStop().
GraphStageLogic.LambdaInHandler
TBD
GraphStageLogic.LambdaOutHandler
TBD
GraphStageWithMaterializedValue<TShape, TMaterialized>
TBD
IgnoreTerminateInput
Input handler that does not terminate the stage upon receiving completion. The stage fails upon receiving a failure.
IgnoreTerminateOutput
Output handler that does not terminate the stage upon cancellation.
InAndOutGraphStageLogic
A GraphStageLogic that implements IInHandler and IOutHandler.
OnUpstreamFinish() calls CompleteStage()
InAndOutHandler
Collection of callbacks for an output port of a GraphStage<TShape> and for an input port of a GraphStage<TShape>
InGraphStageLogic
A GraphStageLogic that implements IInHandler.
InHandler
Collection of callbacks for an input port of a GraphStage<TShape>
OutGraphStageLogic
A GraphStageLogic that implements IOutHandler.
OutHandler
Collection of callbacks for an output port of a GraphStage<TShape>
PushPullGraphStage<TIn, TOut>
TBD
PushPullGraphStageWithMaterializedValue<TIn, TOut, TMat>
TBD
PushPullStage<TIn, TOut>
PushPullStage<TIn, TOut> implementations participate in 1-bounded regions. For every external non-completion signal these stages produce exactly one push or pull signal.
OnPush(TIn, IContext) is called when an element from upstream is available and there is demand from downstream, i.e. in OnPush(TIn, IContext) you are allowed to call Push(Object) to emit one element downstream, or you can absorb the element by calling Pull(). Note that you can only emit zero or one element downstream from OnPull(IContext). To emit more than one element you have to push the remaining elements from OnPush(TIn, IContext), one-by-one. OnPush(TIn, IContext) is not called again until OnPull(IContext) has requested more elements with Pull().
StatefulStage<TIn, TOut> has support for making it easy to emit more than one element from OnPush(TIn, IContext).
OnPull(IContext)> is called when there is demand from downstream, i.e. you are allowed to push one element downstream with Push(Object), or request elements from upstreams with Pull(). If you always perform transitive pull by calling Pull() from OnPull(IContext) you can use PushStage<TIn, TOut> instead of PushPullStage<TIn, TOut>.
Stages are allowed to do early completion of downstream and cancel of upstream. This is done with Akka.Streams.Stage.StatefulStage.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 PushAndFinish(Object) 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 Push(Object) as a response to OnUpstreamFinish(IContext) or OnUpstreamFailure(Exception, IContext) will very likely break boundedness and result in a buffer overflow somewhere. Therefore the only allowed command in this case is AbsorbTermination() which stops the propagation of the termination signal, and puts the stage in a IsFinishing state. Depending on whether the stage has a pending pull signal it has not yet "consumed" by a push its OnPull(IContext) handler might be called immediately or later. From OnPull(IContext) final elements can be pushed before completing downstream with Akka.Streams.Stage.StatefulStage.Finish or PushAndFinish(Object).
StatefulStage<TIn, TOut> 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 IContext method, and do only call IContext commands once per callback.
PushStage<TIn, TOut>
PushStage<TIn, TOut> is a PushPullStage<TIn, TOut> that always perform transitive pull by calling Pull() from OnPull(IContext<TOut>).
StageActor
Minimal actor to work with other actors and watch them in a synchronous ways.
StageActorRef
StageActorRefNotInitializedException
TBD
StageState<TIn, TOut>
The behavior of StatefulStage<TIn, TOut> is defined by these two methods, which has the same semantics as corresponding methods in PushPullStage<TIn, TOut>.
StatefulStage
TBD
StatefulStage<TIn, TOut>
StatefulStage<TIn, TOut> is a PushPullStage<TIn, TOut> that provides convenience to make some things easier.
The behavior is defined in StageState<TIn, TOut> instances. The initial behavior is specified by subclass implementing the Initial method. The behavior can be changed by using Become(StageState<TIn, TOut>).
Use Emit(IEnumerator<TOut>, IContext<TOut>, StageState<TIn, TOut>) or EmitAndFinish(IEnumerator<TOut>, IContext<TOut>) to push more than one element from OnPush(TIn, IContext<TOut>) or OnPull(IContext<TOut>).
Use TerminationEmit(IEnumerator<TOut>, IContext<TOut>) to push final elements from OnUpstreamFinish(IContext<TOut>) or OnUpstreamFailure(Exception, IContext).
TimerGraphStageLogic
TBD
TotallyIgnorantInput
Input handler that does not terminate the stage upon receiving completion nor failure.
Structs
LogicAndMaterializedValue<TMaterialized>
TBD
Interfaces
IAsyncContext
This kind of context is available to IAsyncContext<TOut, TExt>. It implements the same interface as for IDetachedContext with the addition of being able to obtain AsyncCallback objects that allow the registration of asynchronous notifications.
IAsyncContext<TOut, TExt>
TBD
IAsyncDirective
TBD
IBoundaryContext
TBD
IContext
Passed to the callback methods of PushPullStage<TIn, TOut> and StatefulStage<TIn, TOut>.
IContext<TOut>
TBD
IDetachedContext
Passed to the callback methods of DetachedStage<TIn, TOut>.
HoldDownstream() and HoldUpstream() 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(Object) which results in two events making the balance right again: 1 hold + 1 external event = 2 external event
IDetachedContext<TOut>
TBD
IDirective
TBD
IDownstreamDirective
TBD
IGraphStageWithMaterializedValue<TShape, TMaterialized>
TBD
IInHandler
Collection of callbacks for an input port of a GraphStage<TShape>
ILifecycleContext
TBD
ILogicAndMaterializedValue<TMaterialized>
TBD
IOutHandler
Collection of callbacks for an output port of a GraphStage<TShape>
IStage<TIn, TOut>
General interface for stream transformation.
Custom IStage<TIn, TOut> implementations are intended to be used with Transform<TIn, TOut1, TOut2, TMat>(Flow<TIn, TOut1, TMat>, Func<IStage<TOut1, TOut2>>) to extend the FlowOperations API when there is no specialized operator that performs the transformation.
Custom implementations are subclasses of PushPullStage<TIn, TOut> or DetachedStage<TIn, TOut>. Sometimes it is convenient to extend StatefulStage<TIn, TOut> for support of become like behavior.
It is possible to keep state in the concrete IStage<TIn, TOut> instance with ordinary instance variables. The ITransformerLike<TIn, TOut> 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.
IStageLogging
Simple way to obtain a ILoggingAdapter when used together with an ActorMaterializer. If used with a different materializer NoLogger will be returned.
Make sure to only access Log
from GraphStage callbacks (such as Pull
, Push
or the async-callback).
Note, abiding to Attributes.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.
ISyncDirective
TBD
ITerminationDirective
TBD
IUpstreamDirective
TBD
Delegates
AsyncCallback
TBD
AsyncCallback<T>
An asynchronous callback holder that is attached to an IAsyncContext<TOut, TExt>.
Invoking will eventually lead to Akka.Streams.Implementation.Fusing.GraphInterpreter.OnAsyncInput being called.
Dispatch an asynchronous notification. This method is thread-safe and may be invoked from external execution contexts.