Class SimpleInstrumentationContext<T>
- java.lang.Object
-
- graphql.execution.instrumentation.SimpleInstrumentationContext<T>
-
- All Implemented Interfaces:
InstrumentationContext<T>
@PublicApi public class SimpleInstrumentationContext<T> extends java.lang.Object implements InstrumentationContext<T>
A simple implementation ofInstrumentationContext
-
-
Constructor Summary
Constructors Constructor Description SimpleInstrumentationContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> java.util.function.BiConsumer<? super T,? super java.lang.Throwable>
completeInstrumentationCtxCF(InstrumentationContext<T> instrumentationContext, java.util.concurrent.CompletableFuture<T> targetCF)
static <T> @NotNull InstrumentationContext<T>
nonNullCtx(InstrumentationContext<T> nullableContext)
This creates a no-opInstrumentationContext
if the one pass in is nullstatic <T> InstrumentationContext<T>
noOp()
A context that does nothingvoid
onCompleted(T result, java.lang.Throwable t)
This is invoked when the instrumentation step is fully completedvoid
onDispatched(java.util.concurrent.CompletableFuture<T> result)
This is invoked when the instrumentation step is initially dispatchedstatic <U> SimpleInstrumentationContext<U>
whenCompleted(java.util.function.BiConsumer<U,java.lang.Throwable> codeToRun)
Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step completion.static <U> SimpleInstrumentationContext<U>
whenDispatched(java.util.function.Consumer<java.util.concurrent.CompletableFuture<U>> codeToRun)
Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step dispatch.
-
-
-
Method Detail
-
noOp
public static <T> InstrumentationContext<T> noOp()
A context that does nothing- Type Parameters:
T
- the type needed- Returns:
- a context that does nothing
-
nonNullCtx
@NotNull public static <T> @NotNull InstrumentationContext<T> nonNullCtx(InstrumentationContext<T> nullableContext)
This creates a no-opInstrumentationContext
if the one pass in is null- Type Parameters:
T
- for two- Parameters:
nullableContext
- aInstrumentationContext
that can be null- Returns:
- a non null
InstrumentationContext
that maybe a no-op
-
onDispatched
public void onDispatched(java.util.concurrent.CompletableFuture<T> result)
Description copied from interface:InstrumentationContext
This is invoked when the instrumentation step is initially dispatched- Specified by:
onDispatched
in interfaceInstrumentationContext<T>
- Parameters:
result
- the result of the step as a completable future
-
onCompleted
public void onCompleted(T result, java.lang.Throwable t)
Description copied from interface:InstrumentationContext
This is invoked when the instrumentation step is fully completed- Specified by:
onCompleted
in interfaceInstrumentationContext<T>
- Parameters:
result
- the result of the step (which may be null)t
- this exception will be non null if an exception was thrown during the step
-
whenDispatched
public static <U> SimpleInstrumentationContext<U> whenDispatched(java.util.function.Consumer<java.util.concurrent.CompletableFuture<U>> codeToRun)
Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step dispatch.- Type Parameters:
U
- the generic type- Parameters:
codeToRun
- the code to run on dispatch- Returns:
- an instrumentation context
-
whenCompleted
public static <U> SimpleInstrumentationContext<U> whenCompleted(java.util.function.BiConsumer<U,java.lang.Throwable> codeToRun)
Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step completion.- Type Parameters:
U
- the generic type- Parameters:
codeToRun
- the code to run on completion- Returns:
- an instrumentation context
-
completeInstrumentationCtxCF
public static <T> java.util.function.BiConsumer<? super T,? super java.lang.Throwable> completeInstrumentationCtxCF(InstrumentationContext<T> instrumentationContext, java.util.concurrent.CompletableFuture<T> targetCF)
-
-