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 Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> MultiGlobalSpy<T> Spy allMultievents (exceptMulti.onOverflow()).static <T> UniGlobalSpy<T> Spy allUnievents.static <T> MultiOnCancellationSpy<T> onCancellation(Multi<T> upstream) SpyMulti.onCancellation()events.static <T> UniOnCancellationSpy<T> onCancellation(Uni<T> upstream) SpyUni.onCancellation()events.static <T> MultiOnCompletionSpy<T> onCompletion(Multi<T> upstream) SpyMulti.onCompletion()events.static <T> MultiOnFailureSpy<T> SpyMulti.onFailure()events.static <T> MultiOnFailureSpy<T> SpyMulti.onFailure(Class)events.static <T> MultiOnFailureSpy<T> SpyMulti.onFailure(Predicate)events.static <T> UniOnFailureSpy<T> SpyUni.onFailure()events.static <T> UniOnFailureSpy<T> SpyUni.onFailure(Class)events.static <T> UniOnFailureSpy<T> SpyUni.onFailure(Predicate))} events.static <T> MultiOnItemSpy<T> SpyMulti.onItem()events and keep track of the items.static <T> MultiOnItemSpy<T> SpyMulti.onItem()events and optionally keep track of the items.static <T> UniOnItemSpy<T> SpyUni.onItem()events.static <T> UniOnItemOrFailureSpy<T> onItemOrFailure(Uni<T> upstream) SpyUni.onItemOrFailure()events.static <T> MultiOnOverflowSpy<T> onOverflow(Multi<T> upstream, boolean trackItems, Function<MultiOverflowStrategy<? extends T>, Multi<? extends T>> strategyMapper) SpyMulti.onOverflow()events and track dropped items.static <T> MultiOnOverflowSpy<T> onOverflow(Multi<T> upstream, Function<MultiOverflowStrategy<? extends T>, Multi<? extends T>> strategyMapper) SpyMulti.onOverflow()events and track dropped items.static <T> MultiOnRequestSpy<T> SpyMulti.onRequest()events.static <T> MultiOnSubscribeSpy<T> onSubscribe(Multi<T> upstream) SpyMulti.onSubscription()events.static <T> UniOnSubscribeSpy<T> onSubscribe(Uni<T> upstream) SpyUni.onSubscription()events.static <T> MultiOnTerminationSpy<T> onTermination(Multi<T> upstream) SpyMulti.onTermination()events.static <T> UniOnTerminationSpy<T> onTermination(Uni<T> upstream) SpyUni.onTermination()events.
-
Method Details
-
onSubscribe
SpyUni.onSubscription()events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onCancellation
SpyUni.onCancellation()events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onTermination
SpyUni.onTermination()events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onItem
SpyUni.onItem()events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onItemOrFailure
SpyUni.onItemOrFailure()events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onFailure
SpyUni.onFailure()events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onFailure
SpyUni.onFailure(Predicate))} events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstreampredicate- a predicate to match a failure type- Returns:
- a new
Uni
-
onFailure
SpyUni.onFailure(Class)events.- Type Parameters:
T- the item type- Parameters:
upstream- the upstreamtypeOfFailure- the expected failure type- Returns:
- a new
Uni
-
globally
Spy allUnievents.- Type Parameters:
T- the item type- Parameters:
upstream- the upstream- Returns:
- a new
Uni
-
onCancellation
SpyMulti.onCancellation()events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onCompletion
SpyMulti.onCompletion()events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onFailure
SpyMulti.onFailure()events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onFailure
static <T> MultiOnFailureSpy<T> onFailure(Multi<T> upstream, Predicate<? super Throwable> predicate) SpyMulti.onFailure(Predicate)events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstreampredicate- a predicate to match a failure type- Returns:
- a new
Multi
-
onFailure
static <T> MultiOnFailureSpy<T> onFailure(Multi<T> upstream, Class<? extends Throwable> typeOfFailure) SpyMulti.onFailure(Class)events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstreamtypeOfFailure- the type of failure- Returns:
- a new
Multi
-
onItem
SpyMulti.onItem()events and keep track of the items.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onItem
SpyMulti.onItem()events and optionally keep track of the items.- Type Parameters:
T- the items type- Parameters:
upstream- the upstreamtrackItems-truewhen items shall be tracked,falseotherwise- Returns:
- a new
Multi
-
onRequest
SpyMulti.onRequest()events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onSubscribe
SpyMulti.onSubscription()events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onTermination
SpyMulti.onTermination()events.- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-
onOverflow
static <T> MultiOnOverflowSpy<T> onOverflow(Multi<T> upstream, Function<MultiOverflowStrategy<? extends T>, Multi<? extends T>> strategyMapper) SpyMulti.onOverflow()events and track dropped items.- Type Parameters:
T- the items type- Parameters:
upstream- the uptreamstrategyMapper- 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, Function<MultiOverflowStrategy<? extends T>, Multi<? extends T>> strategyMapper) SpyMulti.onOverflow()events and track dropped items.- Type Parameters:
T- the items type- Parameters:
upstream- the uptreamtrackItems-trueif items shall be tracked,falseotherwisestrategyMapper- a function to define the drop strategy applied by the spy- Returns:
- a new
Multi
-
globally
Spy allMultievents (exceptMulti.onOverflow()).The overflow events are not being tracked because they cause the
upstreamto be requestedLong.MAX_VALUEelements, so the behavior of a pipeline can be affected by introducing aMultiOnOverflowSpy.If you want to track overflow events then you will need to explicitly wrap a
MultiwithonOverflow(Multi, Function).- Type Parameters:
T- the items type- Parameters:
upstream- the upstream- Returns:
- a new
Multi
-