akka.stream.scaladsl

Duct

trait Duct[In, +Out] extends AnyRef

A Duct provides the same kind of formulation of stream transformations as a Flow. The difference is that it is not attached to an input source.

The pipeline must be materialized by calling the #produceTo, #consume or #build methods on it and then attach the Consumer representing the input side of the Duct to an upstream Producer.

Source
Duct.scala
Linear Supertypes
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Duct
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def append[U](duct: Duct[_ >: In, U]): Duct[In, U]

    Append the operations of a Duct to this Duct.

  2. abstract def buffer(size: Int, overflowStrategy: OverflowStrategy): Duct[In, Out]

    Adds a fixed size buffer in the flow that allows to store elements from a faster upstream until it becomes full.

    Adds a fixed size buffer in the flow that allows to store elements from a faster upstream until it becomes full. Depending on the defined OverflowStrategy it might drop elements or backpressure the upstream if there is no space available

    size

    The size of the buffer in element count

    overflowStrategy

    Strategy that is used when incoming elements cannot fit inside the buffer

  3. abstract def build(materializer: FlowMaterializer): (Consumer[In], Producer[Out])

    Materialize this Duct into a Consumer representing the input side of the Duct and a Producerrepresenting the output side of the the Duct.

    Materialize this Duct into a Consumer representing the input side of the Duct and a Producerrepresenting the output side of the the Duct.

    The returned Producer can later be connected to an downstream Consumer. The returned Consumer can later be connected to an upstream Producer.

    *This will materialize the flow and initiate its execution.*

    The given FlowMaterializer decides how the flow’s logical structure is broken down into individual processing steps.

  4. abstract def collect[U](pf: PartialFunction[Out, U]): Duct[In, U]

    Transform this stream by applying the given partial function to each of the elements on which the function is defined as they pass through this processing step.

    Transform this stream by applying the given partial function to each of the elements on which the function is defined as they pass through this processing step. Non-matching elements are filtered out.

  5. abstract def concat[U >: Out](next: Producer[U]): Duct[In, U]

    Concatenate the given other stream to this stream so that the first element emitted by the given producer is emitted after the last element of this stream.

  6. abstract def conflate[S](seed: (Out) ⇒ S, aggregate: (S, Out) ⇒ S): Duct[In, S]

    Allows a faster upstream to progress independently of a slower consumer by conflating elements into a summary until the consumer is ready to accept them.

    Allows a faster upstream to progress independently of a slower consumer by conflating elements into a summary until the consumer is ready to accept them. For example a conflate step might average incoming numbers if the upstream producer is faster.

    This element only rolls up elements if the upstream is faster, but if the downstream is faster it will not duplicate elements.

    seed

    Provides the first state for a conflated value using the first unconsumed element as a start

    aggregate

    Takes the currently aggregated value and the current pending element to produce a new aggregate

  7. abstract def consume(materializer: FlowMaterializer): Consumer[In]

    Attaches a consumer to this stream which will just discard all received elements.

    Attaches a consumer to this stream which will just discard all received elements. The returned Consumer represents the input side of the Duct and can later be connected to an upstream Producer.

    *This will materialize the flow and initiate its execution.*

    The given FlowMaterializer decides how the flow’s logical structure is broken down into individual processing steps.

  8. abstract def drop(n: Int): Duct[In, Out]

    Discard the given number of elements at the beginning of the stream.

  9. abstract def dropWithin(d: FiniteDuration): Duct[In, Out]

    Discard the elements received within the given duration at beginning of the stream.

  10. abstract def expand[S, U](seed: (Out) ⇒ S, extrapolate: (S) ⇒ (U, S)): Duct[In, U]

    Allows a faster downstream to progress independently of a slower producer by extrapolating elements from an older element until new element comes from the upstream.

    Allows a faster downstream to progress independently of a slower producer by extrapolating elements from an older element until new element comes from the upstream. For example an expand step might repeat the last element for the consumer until it receives an update from upstream.

    This element will never "drop" upstream elements as all elements go through at least one extrapolation step. This means that if the upstream is actually faster than the upstream it will be backpressured by the downstream consumer.

    seed

    Provides the first state for extrapolation using the first unconsumed element

    extrapolate

    Takes the current extrapolation state to produce an output element and the next extrapolation state.

  11. abstract def filter(p: (Out) ⇒ Boolean): Duct[In, Out]

    Only pass on those elements that satisfy the given predicate.

  12. abstract def flatten[U](strategy: FlattenStrategy[Out, U]): Duct[In, U]

    Transforms a stream of streams into a contiguous stream of elements using the provided flattening strategy.

    Transforms a stream of streams into a contiguous stream of elements using the provided flattening strategy. This operation can be used on a stream of element type Producer.

  13. abstract def fold[U](zero: U)(f: (U, Out) ⇒ U): Duct[In, U]

    Invoke the given function for every received element, giving it its previous output (or the given “zero” value) and the element as input.

    Invoke the given function for every received element, giving it its previous output (or the given “zero” value) and the element as input. The returned stream will receive the return value of the final function evaluation when the input stream ends.

  14. abstract def foreach(c: (Out) ⇒ Unit): Duct[In, Unit]

    Invoke the given procedure for each received element and produce a Unit value upon reaching the normal end of the stream.

    Invoke the given procedure for each received element and produce a Unit value upon reaching the normal end of the stream. Please note that also in this case the Duct needs to be materialized (e.g. using #consume and attaching the the Consumer representing the input side of the Duct to an upstream Producer) to initiate its execution.

  15. abstract def groupBy[K](f: (Out) ⇒ K): Duct[In, (K, Producer[Out])]

    This operation demultiplexes the incoming stream into separate output streams, one for each element key.

    This operation demultiplexes the incoming stream into separate output streams, one for each element key. The key is computed for each element using the given function. When a new key is encountered for the first time it is emitted to the downstream consumer together with a fresh producer that will eventually produce all the elements of the substream for that key. Not consuming the elements from the created streams will stop this processor from processing more elements, therefore you must take care to unblock (or cancel) all of the produced streams even if you want to consume only one of them.

  16. abstract def grouped(n: Int): Duct[In, Seq[Out]]

    Chunk up this stream into groups of the given size, with the last group possibly smaller than requested due to end-of-stream.

  17. abstract def groupedWithin(n: Int, d: FiniteDuration): Duct[In, Seq[Out]]

    Chunk up this stream into groups of elements received within a time window, or limited by the given number of elements, whatever happens first.

    Chunk up this stream into groups of elements received within a time window, or limited by the given number of elements, whatever happens first. Empty groups will not be emitted if no elements are received from upstream. The last group before end-of-stream will contain the buffered elements since the previously emitted group.

  18. abstract def map[U](f: (Out) ⇒ U): Duct[In, U]

    Transform this stream by applying the given function to each of the elements as they pass through this processing step.

  19. abstract def mapConcat[U](f: (Out) ⇒ Seq[U]): Duct[In, U]

    Transform each input element into a sequence of output elements that is then flattened into the output stream.

  20. abstract def mapFuture[U](f: (Out) ⇒ Future[U]): Duct[In, U]

    Transform this stream by applying the given function to each of the elements as they pass through this processing step.

    Transform this stream by applying the given function to each of the elements as they pass through this processing step. The function returns a Future of the element that will be emitted downstream. As many futures as requested elements by downstream may run in parallel and may complete in any order, but the elements that are emitted downstream are in the same order as from upstream.

  21. abstract def merge[U >: Out](other: Producer[U]): Duct[In, U]

    Merge this stream with the one emitted by the given producer, taking elements as they arrive from either side (picking randomly when both have elements ready).

  22. abstract def onComplete(materializer: FlowMaterializer)(callback: (Try[Unit]) ⇒ Unit): Consumer[In]

    When this flow is completed, either through an error or normal completion, apply the provided function with scala.util.Success or scala.util.Failure.

    When this flow is completed, either through an error or normal completion, apply the provided function with scala.util.Success or scala.util.Failure. The returned Consumer represents the input side of the Duct and can later be connected to an upstream Producer.

    *This operation materializes the flow and initiates its execution.*

  23. abstract def prefixAndTail(n: Int): Duct[In, (Seq[Out], Producer[Out])]

    Takes up to n elements from the stream and returns a pair containing a strict sequence of the taken element and a stream representing the remaining elements.

    Takes up to n elements from the stream and returns a pair containing a strict sequence of the taken element and a stream representing the remaining elements. If n is zero or negative, then this will return a pair of an empty collection and a stream containing the whole upstream unchanged.

  24. abstract def produceTo(materializer: FlowMaterializer, consumer: Consumer[Out]): Consumer[In]

    Materialize this Duct by attaching it to the specified downstream consumer and return a Consumer representing the input side of the Duct.

    Materialize this Duct by attaching it to the specified downstream consumer and return a Consumer representing the input side of the Duct. The returned Consumer can later be connected to an upstream Producer.

    *This will materialize the flow and initiate its execution.*

    The given FlowMaterializer decides how the flow’s logical structure is broken down into individual processing steps.

  25. abstract def splitWhen(p: (Out) ⇒ Boolean): Duct[In, Producer[Out]]

    This operation applies the given predicate to all incoming elements and emits them to a stream of output streams, always beginning a new one with the current element if the given predicate returns true for it.

    This operation applies the given predicate to all incoming elements and emits them to a stream of output streams, always beginning a new one with the current element if the given predicate returns true for it. This means that for the following series of predicate values, three substreams will be produced with lengths 1, 2, and 3:

    false,             // element goes into first substream
    true, false,       // elements go into second substream
    true, false, false // elements go into third substream
  26. abstract def take(n: Int): Duct[In, Out]

    Terminate processing (and cancel the upstream producer) after the given number of elements.

    Terminate processing (and cancel the upstream producer) after the given number of elements. Due to input buffering some elements may have been requested from upstream producers that will then not be processed downstream of this step.

  27. abstract def takeWithin(d: FiniteDuration): Duct[In, Out]

    Terminate processing (and cancel the upstream producer) after the given duration.

    Terminate processing (and cancel the upstream producer) after the given duration. Due to input buffering some elements may have been requested from upstream producers that will then not be processed downstream of this step.

    Note that this can be combined with #take to limit the number of elements within the duration.

  28. abstract def tee(other: Consumer[_ >: Out]): Duct[In, Out]

    Fan-out the stream to another consumer.

    Fan-out the stream to another consumer. Each element is produced to the other consumer as well as to downstream consumers. It will not shutdown until the subscriptions for other and at least one downstream consumer have been established.

  29. abstract def transform[U](transformer: Transformer[Out, U]): Duct[In, U]

    Generic transformation of a stream: for each element the Transformer#onNext function is invoked and expecting a (possibly empty) sequence of output elements to be produced.

    Generic transformation of a stream: for each element the Transformer#onNext function is invoked and expecting a (possibly empty) sequence of output elements to be produced. After handing off the elements produced from one input element to the downstream consumers, the Transformer#isComplete predicate determines whether to end stream processing at this point; in that case the upstream subscription is canceled. Before signaling normal completion to the downstream consumers, the Transformer#onComplete function is invoked to produce a (possibly empty) sequence of elements in response to the end-of-stream event.

    After normal completion or error the Transformer#cleanup function is called.

    It is possible to keep state in the concrete Transformer instance with ordinary instance variables. The Transformer is executed by an actor and therefore you don not have to add any additional thread safety or memory visibility constructs to access the state from the callback methods.

    Note that you can use akka.stream.TimerTransformer if you need support for scheduled events in the transformer.

  30. abstract def zip[U](other: Producer[U]): Duct[In, (Out, U)]

    Zip this stream together with the one emitted by the given producer.

    Zip this stream together with the one emitted by the given producer. This transformation finishes when either input stream reaches its end, cancelling the subscription to the other one.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to any2stringadd[Duct[In, Out]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Duct[In, Out], B)

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to ArrowAssoc[Duct[In, Out]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def ensuring(cond: (Duct[In, Out]) ⇒ Boolean, msg: ⇒ Any): Duct[In, Out]

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to Ensuring[Duct[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (Duct[In, Out]) ⇒ Boolean): Duct[In, Out]

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to Ensuring[Duct[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: ⇒ Any): Duct[In, Out]

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to Ensuring[Duct[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): Duct[In, Out]

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to Ensuring[Duct[In, Out]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to StringFormat[Duct[In, Out]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  23. def toString(): String

    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. def [B](y: B): (Duct[In, Out], B)

    Implicit information
    This member is added by an implicit conversion from Duct[In, Out] to ArrowAssoc[Duct[In, Out]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Duct[In, Out] to any2stringadd[Duct[In, Out]]

Inherited by implicit conversion StringFormat from Duct[In, Out] to StringFormat[Duct[In, Out]]

Inherited by implicit conversion Ensuring from Duct[In, Out] to Ensuring[Duct[In, Out]]

Inherited by implicit conversion ArrowAssoc from Duct[In, Out] to ArrowAssoc[Duct[In, Out]]

Ungrouped