-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixed deferred support to have proper Instrumentation #4083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test Results 325 files - 650 325 suites - 650 3m 29s ⏱️ - 7m 7s Results for commit 215be0b. ± Comparison against base commit 3ba9750. This pull request removes 541 and adds 172 tests. Note that renamed tests count towards both.
This pull request skips 1 test.
♻️ This comment has been updated with latest results. |
private final Map<String, Supplier<CompletableFuture<DeferredFragmentCall.FieldWithExecutionResult>>> dfCache = new HashMap<>(); | ||
|
||
public DeferredExecutionSupportImpl( | ||
MergedSelectionSet mergedSelectionSet, | ||
ExecutionStrategyParameters parameters, | ||
ExecutionContext executionContext, | ||
BiFunction<ExecutionContext, ExecutionStrategyParameters, CompletableFuture<FieldValueInfo>> resolveFieldWithInfoFn | ||
BiFunction<ExecutionContext, ExecutionStrategyParameters, CompletableFuture<FieldValueInfo>> resolveFieldWithInfoFn, | ||
BiFunction<ExecutionContext, ExecutionStrategyParameters, Supplier<ExecutionStepInfo>> executionStepInfoFn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to be able to build the ExecutionStepInfo later and this allows me to do that back in the execution strategy
key -> FpKit.interThreadMemoize(() -> { | ||
CompletableFuture<FieldValueInfo> fieldValueResult = resolveFieldWithInfoFn.apply(executionContext, executionStrategyParameters); | ||
key -> FpKit.interThreadMemoize(resolveDeferredFieldValue(currentField, executionContext, executionStrategyParameters) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved most of the code into a method resolveDeferredFieldValue
- just because it was a lambda in a lambda
public InstrumentationContext<Object> beginDeferredField(InstrumentationState instrumentationState) { | ||
return new ChainedDeferredExecutionStrategyInstrumentationContext(chainedMapAndDropNulls(instrumentationState, Instrumentation::beginDeferredField)); | ||
public InstrumentationContext<Object> beginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) { | ||
return chainedCtx(state, (instrumentation, specificState) -> instrumentation.beginDeferredField(parameters, specificState)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just wrong and it had not tests
*/ | ||
@ExperimentalApi | ||
default InstrumentationContext<Object> beginDeferredField(InstrumentationState state) { | ||
default InstrumentationContext<Object> beginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) { | ||
return noOp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we now have field parameters
@@ -1096,6 +1097,11 @@ protected ExecutionStepInfo createExecutionStepInfo(ExecutionContext executionCo | |||
fieldContainer); | |||
} | |||
|
|||
private Supplier<ExecutionStepInfo> createExecutionStepInfo(ExecutionContext executionContext, ExecutionStrategyParameters parameters) { | |||
GraphQLFieldDefinition fieldDef = getFieldDef(executionContext, parameters, parameters.getField().getSingleField()); | |||
return FpKit.intraThreadMemoize(() -> createExecutionStepInfo(executionContext, parameters, fieldDef, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to be able to create a ExecutionStepInfo for a field but later
The current deferred field Instrumentation is broken - it has no arguments and its context is never called back.
This implements it more properly. It calls beingDeferredField each time a field actually gets started - eg after the main operation has finished and we begin to drain the deferred queue