Interface Spy


  • @Experimental("We are experimenting with spies for diagnosis and testing")
    public interface Spy
    Helpers for creating Uni and Multi spies to observe events. A spy is a transparent operator that can be plugged into a pipeline to help diagnose what events flow. It observes how many times a given event has been observed. Depending on the event type it will also report values, such as the last observed failure or termination. It is important to note that spies observe and report events for all subscribers, not just one in particular.
    • Method Detail

      • onItem

        static <T> UniOnItemSpy<T> onItem​(Uni<T> upstream)
        Spy Uni.onItem() events.
        Type Parameters:
        T - the item type
        Parameters:
        upstream - the upstream
        Returns:
        a new Uni
      • onFailure

        static <T> UniOnFailureSpy<T> onFailure​(Uni<T> upstream)
        Spy Uni.onFailure() events.
        Type Parameters:
        T - the item type
        Parameters:
        upstream - the upstream
        Returns:
        a new Uni
      • onFailure

        static <T> UniOnFailureSpy<T> onFailure​(Uni<T> upstream,
                                                java.util.function.Predicate<? super java.lang.Throwable> predicate)
        Type Parameters:
        T - the item type
        Parameters:
        upstream - the upstream
        predicate - a predicate to match a failure type
        Returns:
        a new Uni
      • onFailure

        static <T> UniOnFailureSpy<T> onFailure​(Uni<T> upstream,
                                                java.lang.Class<? extends java.lang.Throwable> typeOfFailure)
        Type Parameters:
        T - the item type
        Parameters:
        upstream - the upstream
        typeOfFailure - the expected failure type
        Returns:
        a new Uni
      • globally

        static <T> UniGlobalSpy<T> globally​(Uni<T> upstream)
        Spy all Uni events.
        Type Parameters:
        T - the item type
        Parameters:
        upstream - the upstream
        Returns:
        a new Uni
      • onFailure

        static <T> MultiOnFailureSpy<T> onFailure​(Multi<T> upstream,
                                                  java.util.function.Predicate<? super java.lang.Throwable> predicate)
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the upstream
        predicate - a predicate to match a failure type
        Returns:
        a new Multi
      • onFailure

        static <T> MultiOnFailureSpy<T> onFailure​(Multi<T> upstream,
                                                  java.lang.Class<? extends java.lang.Throwable> typeOfFailure)
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the upstream
        typeOfFailure - the type of failure
        Returns:
        a new Multi
      • onItem

        static <T> MultiOnItemSpy<T> onItem​(Multi<T> upstream)
        Spy Multi.onItem() events and keep track of the items.
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the upstream
        Returns:
        a new Multi
      • onItem

        static <T> MultiOnItemSpy<T> onItem​(Multi<T> upstream,
                                            boolean trackItems)
        Spy Multi.onItem() events and optionally keep track of the items.
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the upstream
        trackItems - true when items shall be tracked, false otherwise
        Returns:
        a new Multi
      • onOverflow

        static <T> MultiOnOverflowSpy<T> onOverflow​(Multi<T> upstream,
                                                    java.util.function.Function<MultiOverflowStrategy<? extends T>,​Multi<? extends T>> strategyMapper)
        Spy Multi.onOverflow() events and track dropped items.
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the uptream
        strategyMapper - a function to define the drop strategy applied by the spy
        Returns:
        a new Multi
      • onOverflow

        static <T> MultiOnOverflowSpy<T> onOverflow​(Multi<T> upstream,
                                                    boolean trackItems,
                                                    java.util.function.Function<MultiOverflowStrategy<? extends T>,​Multi<? extends T>> strategyMapper)
        Spy Multi.onOverflow() events and track dropped items.
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the uptream
        trackItems - true if items shall be tracked, false otherwise
        strategyMapper - a function to define the drop strategy applied by the spy
        Returns:
        a new Multi
      • globally

        static <T> MultiGlobalSpy<T> globally​(Multi<T> upstream)
        Spy all Multi events (except Multi.onOverflow()). The overflow events are not being tracked because they cause the upstream to be requested Long.MAX_VALUE elements, so the behavior of a pipeline can be affected by introducing a MultiOnOverflowSpy. If you want to track overflow events then you will need to explicitly wrap a Multi with onOverflow(Multi, Function).
        Type Parameters:
        T - the items type
        Parameters:
        upstream - the upstream
        Returns:
        a new Multi