Class SimpleInstrumentationContext<T>
java.lang.Object
graphql.execution.instrumentation.SimpleInstrumentationContext<T>
- All Implemented Interfaces:
InstrumentationContext<T>
@PublicApi
public class SimpleInstrumentationContext<T>
extends Object
implements InstrumentationContext<T>
A simple implementation of
InstrumentationContext-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BiConsumer<T, Throwable> private final Consumer<CompletableFuture<T>> private static final InstrumentationContext<Object> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSimpleInstrumentationContext(Consumer<CompletableFuture<T>> codeToRunOnDispatch, BiConsumer<T, Throwable> codeToRunOnComplete) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BiConsumer<? super T, ? super Throwable> completeInstrumentationCtxCF(InstrumentationContext<T> instrumentationContext, CompletableFuture<T> targetCF) static <T> @NotNull InstrumentationContext<T> nonNullCtx(InstrumentationContext<T> nullableContext) This creates a no-opInstrumentationContextif the one pass in is nullstatic <T> InstrumentationContext<T> noOp()A context that does nothingvoidonCompleted(T result, Throwable t) This is invoked when the instrumentation step is fully completedvoidonDispatched(CompletableFuture<T> result) This is invoked when the instrumentation step is initially dispatchedstatic <U> SimpleInstrumentationContext<U> whenCompleted(BiConsumer<U, 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(Consumer<CompletableFuture<U>> codeToRun) Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step dispatch.
-
Field Details
-
NO_OP
-
codeToRunOnComplete
-
codeToRunOnDispatch
-
-
Constructor Details
-
SimpleInstrumentationContext
public SimpleInstrumentationContext() -
SimpleInstrumentationContext
private SimpleInstrumentationContext(Consumer<CompletableFuture<T>> codeToRunOnDispatch, BiConsumer<T, Throwable> codeToRunOnComplete)
-
-
Method Details
-
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-opInstrumentationContextif the one pass in is null- Type Parameters:
T- for two- Parameters:
nullableContext- aInstrumentationContextthat can be null- Returns:
- a non null
InstrumentationContextthat maybe a no-op
-
onDispatched
Description copied from interface:InstrumentationContextThis is invoked when the instrumentation step is initially dispatched- Specified by:
onDispatchedin interfaceInstrumentationContext<T>- Parameters:
result- the result of the step as a completable future
-
onCompleted
Description copied from interface:InstrumentationContextThis is invoked when the instrumentation step is fully completed- Specified by:
onCompletedin 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(Consumer<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
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> BiConsumer<? super T,? super Throwable> completeInstrumentationCtxCF(InstrumentationContext<T> instrumentationContext, CompletableFuture<T> targetCF)
-