Interface ReactiveStreamsEngine


  • public interface ReactiveStreamsEngine
    An engine for turning reactive streams graphs into Reactive Streams publishers/subscribers.

    The zero argument build and run methods on subclasses of this will use the ServiceLoader to load an engine for the current context classloader. It does not cache engines between invocations. If instantiating an engine is expensive (eg, it creates threads), then it is recommended that the implementation does its own caching by providing the engine using a static provider method.

    • Method Detail

      • buildPublisher

        <T> org.reactivestreams.Publisher<T> buildPublisher​(Graph graph)
                                                     throws UnsupportedStageException
        Build a Publisher from the given stages.

        The passed in graph will have an outlet and no inlet.

        Type Parameters:
        T - The type of elements that the publisher publishes.
        Parameters:
        graph - The stages to build the publisher from. Will not be empty.
        Returns:
        A publisher that implements the passed in graph of stages.
        Throws:
        UnsupportedStageException - If a stage in the stages is not supported by this Reactive Streams engine.
      • buildSubscriber

        <T,​R> SubscriberWithCompletionStage<T,​R> buildSubscriber​(Graph graph)
                                                                      throws UnsupportedStageException
        Build a Subscriber from the given stages.

        The passed in graph will have an inlet and no outlet.

        Type Parameters:
        T - The type of elements that the subscriber subscribes to.
        R - The result of subscribing to the stages.
        Parameters:
        graph - The graph to build the subscriber from. Will not be empty.
        Returns:
        A subscriber that implements the passed in graph of stages.
        Throws:
        UnsupportedStageException - If a stage in the stages is not supported by this Reactive Streams engine.
      • buildProcessor

        <T,​R> org.reactivestreams.Processor<T,​R> buildProcessor​(Graph graph)
                                                                     throws UnsupportedStageException
        Build a Processor from the given stages.

        The passed in graph will have an inlet and an outlet.

        Type Parameters:
        T - The type of elements that the processor subscribes to.
        R - The type of elements that the processor publishes.
        Parameters:
        graph - The graph to build the processor from. If empty, then the processor should be an identity processor.
        Returns:
        A processor that implements the passed in graph of stages.
        Throws:
        UnsupportedStageException - If a stage in the stages is not supported by this Reactive Streams engine.
      • buildCompletion

        <T> java.util.concurrent.CompletionStage<T> buildCompletion​(Graph graph)
                                                             throws UnsupportedStageException
        Build a closed graph from the given stages.

        The passed in graph will have no inlet and no outlet.

        Type Parameters:
        T - The type of the result of running the closed graph.
        Parameters:
        graph - The graph to build the closed graph from. Will not be empty.
        Returns:
        A CompletionStage of the result of running the graph.
        Throws:
        UnsupportedStageException - If a stage in the stages is not supported by this reactive streams engine.