Packages

o

akka.stream.scaladsl

PartitionHub

object PartitionHub

A PartitionHub is a special streaming hub that is able to route streamed elements to a dynamic set of consumers. It consists of two parts, a Sink and a Source. The Sink e elements from a producer to the actually live consumers it has. The selection of consumer is done with a function. Each element can be routed to only one consumer. Once the producer has been materialized, the Sink it feeds into returns a materialized value which is the corresponding Source. This Source can be materialized an arbitrary number of times, where each of the new materializations will receive their elements from the original Sink.

Source
Hub.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. PartitionHub
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. trait ConsumerInfo extends javadsl.PartitionHub.ConsumerInfo
    Annotations
    @DoNotInherit()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. def sink[T](partitioner: (Int, T) => Int, startAfterNrOfConsumers: Int, bufferSize: Int = defaultBufferSize): Sink[T, Source[T, NotUsed]]

    Creates a Sink that receives elements from its upstream producer and routes them to a dynamic set of consumers.

    Creates a Sink that receives elements from its upstream producer and routes them to a dynamic set of consumers. After the Sink returned by this method is materialized, it returns a Source as materialized value. This Source can be materialized an arbitrary number of times and each materialization will receive the elements from the original Sink.

    Every new materialization of the Sink results in a new, independent hub, which materializes to its own Source for consuming the Sink of that materialization.

    If the original Sink is failed, then the failure is immediately propagated to all of its materialized Sources (possibly jumping over already buffered elements). If the original Sink is completed, then all corresponding Sources are completed. Both failure and normal completion is "remembered" and later materializations of the Source will see the same (failure or completion) state. Sources that are cancelled are simply removed from the dynamic set of consumers.

    This sink should be used when the routing function is stateless, e.g. based on a hashed value of the elements. Otherwise the #statefulSink can be used to implement more advanced routing logic.

    partitioner

    Function that decides where to route an element. The function takes two parameters; the first is the number of active consumers and the second is the stream element. The function should return the index of the selected consumer for the given element, i.e. int greater than or equal to 0 and less than number of consumers. E.g. (size, elem) => math.abs(elem.hashCode % size). It's also possible to use -1 to drop the element.

    startAfterNrOfConsumers

    Elements are buffered until this number of consumers have been connected. This is only used initially when the operator is starting up, i.e. it is not honored when consumers have been removed (canceled).

    bufferSize

    Total number of elements that can be buffered. If this buffer is full, the producer is backpressured.

  15. def statefulSink[T](partitioner: () => (ConsumerInfo, T) => Long, startAfterNrOfConsumers: Int, bufferSize: Int = defaultBufferSize): Sink[T, Source[T, NotUsed]]

    Creates a Sink that receives elements from its upstream producer and routes them to a dynamic set of consumers.

    Creates a Sink that receives elements from its upstream producer and routes them to a dynamic set of consumers. After the Sink returned by this method is materialized, it returns a Source as materialized value. This Source can be materialized an arbitrary number of times and each materialization will receive the elements from the original Sink.

    Every new materialization of the Sink results in a new, independent hub, which materializes to its own Source for consuming the Sink of that materialization.

    If the original Sink is failed, then the failure is immediately propagated to all of its materialized Sources (possibly jumping over already buffered elements). If the original Sink is completed, then all corresponding Sources are completed. Both failure and normal completion is "remembered" and later materializations of the Source will see the same (failure or completion) state. Sources that are cancelled are simply removed from the dynamic set of consumers.

    This statefulSink should be used when there is a need to keep mutable state in the partition function, e.g. for implementing round-robin or sticky session kind of routing. If state is not needed the #sink can be more convenient to use.

    partitioner

    Function that decides where to route an element. It is a factory of a function to to be able to hold stateful variables that are unique for each materialization. The function takes two parameters; the first is information about active consumers, including an array of consumer identifiers and the second is the stream element. The function should return the selected consumer identifier for the given element. The function will never be called when there are no active consumers, i.e. there is always at least one element in the array of identifiers.

    startAfterNrOfConsumers

    Elements are buffered until this number of consumers have been connected. This is only used initially when the operator is starting up, i.e. it is not honored when consumers have been removed (canceled).

    bufferSize

    Total number of elements that can be buffered. If this buffer is full, the producer is backpressured.

  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped