Package org.apache.pekko.stream.scaladsl
Class Partition<T>
- java.lang.Object
-
- org.apache.pekko.stream.stage.GraphStageWithMaterializedValue<S,NotUsed>
-
- org.apache.pekko.stream.stage.GraphStage<UniformFanOutShape<T,T>>
-
- org.apache.pekko.stream.scaladsl.Partition<T>
-
- All Implemented Interfaces:
Graph<UniformFanOutShape<T,T>,NotUsed>
public final class Partition<T> extends GraphStage<UniformFanOutShape<T,T>>
Fan-out the stream to several streams. emitting an incoming upstream element to one downstream consumer according to the partitioner function applied to the elementAdheres to the
ActorAttributes.SupervisionStrategy
attribute.'''Emits when''' emits when an element is available from the input and the chosen output has demand
'''Backpressures when''' the currently chosen output back-pressures
'''Completes when''' upstream completes and no output is pending
'''Cancels when''' all downstreams have cancelled (eagerCancel=false) or one downstream cancels (eagerCancel=true)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Partition.PartitionOutOfBoundsException
static class
Partition.PartitionOutOfBoundsException$
-
Nested classes/interfaces inherited from interface org.apache.pekko.stream.Graph
Graph.GraphMapMatVal<S extends Shape,M>
-
-
Constructor Summary
Constructors Constructor Description Partition(int outputPorts, scala.Function1<T,java.lang.Object> partitioner)
Deprecated.Use the constructor which also specifies the `eagerCancel` parameter.Partition(int outputPorts, scala.Function1<T,java.lang.Object> partitioner, boolean eagerCancel)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Partition<T>
apply(int outputPorts, scala.Function1<T,java.lang.Object> partitioner)
Create a newPartition
operator with the specified input type.GraphStageLogic
createLogic(Attributes inheritedAttributes)
boolean
eagerCancel()
Inlet<T>
in()
scala.collection.immutable.Seq<Outlet<T>>
out()
int
outputPorts()
scala.Function1<T,java.lang.Object>
partitioner()
UniformFanOutShape<T,T>
shape()
The shape of a graph is all that is externally visible: its inlets and outlets.java.lang.String
toString()
-
Methods inherited from class org.apache.pekko.stream.stage.GraphStage
createLogicAndMaterializedValue
-
Methods inherited from class org.apache.pekko.stream.stage.GraphStageWithMaterializedValue
initialAttributes, withAttributes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.pekko.stream.Graph
addAttributes, async, async, async, getAttributes, named
-
-
-
-
Constructor Detail
-
Partition
public Partition(int outputPorts, scala.Function1<T,java.lang.Object> partitioner, boolean eagerCancel)
-
Partition
public Partition(int outputPorts, scala.Function1<T,java.lang.Object> partitioner)
Deprecated.Use the constructor which also specifies the `eagerCancel` parameter. Since Akka 2.5.10.SetseagerCancel
tofalse
.
-
-
Method Detail
-
apply
public static <T> Partition<T> apply(int outputPorts, scala.Function1<T,java.lang.Object> partitioner)
Create a newPartition
operator with the specified input type. This method setseagerCancel
tofalse
. To specify a different value for theeagerCancel
parameter, then instantiate Partition using the constructor.If
eagerCancel
is true, partition cancels upstream if any of its downstreams cancel, if false, when all have cancelled.- Parameters:
outputPorts
- number of output portspartitioner
- function deciding which output each element will be targeted
-
outputPorts
public int outputPorts()
-
partitioner
public scala.Function1<T,java.lang.Object> partitioner()
-
eagerCancel
public boolean eagerCancel()
-
shape
public UniformFanOutShape<T,T> shape()
Description copied from interface:Graph
The shape of a graph is all that is externally visible: its inlets and outlets.
-
createLogic
public GraphStageLogic createLogic(Attributes inheritedAttributes)
- Specified by:
createLogic
in classGraphStage<UniformFanOutShape<T,T>>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-