Class 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.
Inheritance
Implements
Inherited Members
Namespace: Akka.Streams.Stage
Assembly: Akka.Streams.dll
Syntax
[Obsolete("Please use GraphStage instead. [1.1.0]")]
public abstract class PushPullStage<TIn, TOut> : AbstractStage<TIn, TOut, ISyncDirective, ISyncDirective, IContext<TOut>>, IStage<TIn, TOut>
Type Parameters
Name | Description |
---|---|
TIn | TBD |
TOut | TBD |