Added support for async create state in instrumentmentations#3302
Merged
Added support for async create state in instrumentmentations#3302
Conversation
bbakerman
commented
Aug 25, 2023
| logNotSafe.debug("Executing request. operation name: '{}'. query: '{}'. variables '{}'", executionInput.getOperationName(), executionInput.getQuery(), executionInput.getVariables()); | ||
| } | ||
| executionInput = ensureInputHasId(executionInput); | ||
| ExecutionInput executionInputWithId = ensureInputHasId(executionInput); |
Member
Author
There was a problem hiding this comment.
not effectivly final so we use new variable names
bbakerman
commented
Aug 25, 2023
| CompletableFuture<ExecutionResult> beginExecutionCF = new CompletableFuture<>(); | ||
| InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema, instrumentationState); | ||
| InstrumentationContext<ExecutionResult> executionInstrumentation = nonNullCtx(instrumentation.beginExecution(instrumentationParameters, instrumentationState)); | ||
| executionInstrumentation.onDispatched(beginExecutionCF); |
Member
Author
There was a problem hiding this comment.
All this moves into the thenCompose() of state creation
bbakerman
commented
Aug 25, 2023
| @Override | ||
| public @Nullable InstrumentationState createState(InstrumentationCreateStateParameters parameters) { | ||
| return Assert.assertShouldNeverHappen("createStateAsync should only ever be used"); | ||
| } |
Member
Author
There was a problem hiding this comment.
Looks like it moved but it didnt
bbakerman
commented
Aug 25, 2023
| Async.CombinedBuilder<InstrumentationState> builder = Async.ofExpectedSize(instrumentations.size()); | ||
| for (Instrumentation instrumentation : instrumentations) { | ||
| // state can be null including the CF so handle that | ||
| CompletableFuture<InstrumentationState> stateCF = Async.orNullCompletedFuture(instrumentation.createStateAsync(parameters)); |
Member
Author
There was a problem hiding this comment.
we allow null to come back from instrumentation states inline with how it was able to be null before so we have Async.orNullCompletedFuture to handle this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createState() today is a sync call. but if you had to call some remote system to get state setup then you need a CF to represent this
This PR changes create state to be a async call