Interface Stage.FlatMapCompletionStage

  • All Superinterfaces:
    Stage
    Enclosing interface:
    Stage

    public static interface Stage.FlatMapCompletionStage
    extends Stage
    A flat map stage that emits and flattens CompletionStage.

    The flat map stage must execute the given mapper on each element, and concatenate the values redeemed by the CompletionStage's emitted by the mapper function into the resulting stream.

    The engine must ensure only one mapper function is executed at a time, with the next mapper function not executing until the CompletionStage returned by the previous mapper function has been redeemed.

    Any RuntimeException thrown by the function must be propagated downstream as an error, and upstream must be cancelled. Any subsequent elements received from upstream before the cancellation signal is handled must be dropped.

    If downstream cancels, then upstream must be cancelled, and if there is a currently executing CompletionStage, its result must be ignored.

    If a CompletionStage is redeemed with an error, upstream must be cancelled, and the error must be propagated downstream. Any subsequent elements received from upstream before the cancellation signal is handled must be dropped.

    If upstream terminates with an error, then implementations may decide to ignore the result of any currently executing CompletionStage, and propagate the error immediately, or they may wait for the CompletionStage to be redeemed, emit its result, and then propagate the error downstream. For the purpose of failing fast, so that network failures can be detected and handled, it is recommended, but not required, that the failure is propagated downstream as soon as possible, and the result of the CompletionStage ignored.

    • Method Detail

      • getMapper

        java.util.function.Function<?,​java.util.concurrent.CompletionStage<?>> getMapper()
        The mapper function.
        Returns:
        The mapper function.