mapAsync

Pass incoming elements to a function that return a Future CompletionStage result.

Asynchronous operators

Signature

def mapAsync[T](parallelism: Int)(f: Out ⇒ Future[T]): Repr[T]

Description

Pass incoming elements to a function that return a Future CompletionStage result. When the Future CompletionStage arrives the result is passed downstream. Up to n elements can be processed concurrently, but regardless of their completion time the incoming order will be kept when results complete. For use cases where order does not matter mapAsyncUnordered can be used.

If a Future CompletionStage fails, the stream also fails (unless a different supervision strategy is applied)

emits when the Future CompletionStage returned by the provided function finishes for the next element in sequence

backpressures when the number of Future s CompletionStage s reaches the configured parallelism and the downstream backpressures

completes when upstream completes and all Future s CompletionStage s has been completed and all elements has been emitted

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.