Interface Stage.FlatMap

  • All Superinterfaces:
    Stage
    Enclosing interface:
    Stage

    public static interface Stage.FlatMap
    extends Stage
    A flat map stage.

    The flat map stage must execute the given mapper on each element, and concatenate the publishers emitted by the mapper function into the resulting stream.

    The graph emitted by the mapper function is guaranteed to have an outlet but no inlet.

    The engine must ensure only one publisher emitted by the mapper function is running at a time.

    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 both the currently running inner publisher produced by the mapper, if one is currently running, and the outer upstream, must be cancelled.

    If the inner publisher terminates with an error, the outer publisher 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 the outer publisher terminates with an error, then implementations may cancel the inner publisher, if one is currently running, immediately, or they may wait for the inner publisher to complete, before propagating 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 inner publisher is cancelled as soon as possible.

    • Method Detail

      • getMapper

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