Conversation
| */ | ||
| @SuppressWarnings("TypeParameterUnusedInFormals") | ||
| @PublicApi | ||
| public class InstrumentationReactiveResultsParameters { |
There was a problem hiding this comment.
New parameters for the Instrumentation method
| @Nullable | ||
| default InstrumentationContext<Void> beginReactiveResults(InstrumentationReactiveResultsParameters parameters, InstrumentationState state) { | ||
| return noOp(); | ||
| } |
There was a problem hiding this comment.
Notice how its Void - the end of a Publisher has no result object - it has many objects but there is no actual result at the end
| */ | ||
| public static <T> Publisher<T> whenPublisherFinishes(Publisher<T> publisher, Consumer<? super Throwable> atTheEndCallback) { | ||
| return new AtTheEndPublisher<>(publisher, atTheEndCallback); | ||
| } |
There was a problem hiding this comment.
This helper allows us to wrap a Publisher so that a callback is made when its finished.
| } else { | ||
| mappingPublisher = new CompletionStageMappingPublisher<>(upstreamPublisher, mapper); | ||
| } | ||
| publisher = ReactiveSupport.whenPublisherFinishes(mappingPublisher, whenDone); |
There was a problem hiding this comment.
we now delegate and invoke the whenDone callback
|
|
||
| // | ||
| // wrap this Publisher into one that can call us back when the publishing is done either in error or successful | ||
| publisher = ReactiveSupport.whenPublisherFinishes(publisher, throwable -> ctx.onCompleted(null, throwable)); |
There was a problem hiding this comment.
Same here - we delegate to the original Publisher but the callback here is done when the Publisher is finished
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 598be6a. ♻️ This comment has been updated with latest results. |
…ainedInstrumentation fixups
| reactiveCtx.onDispatched(); | ||
|
|
||
| SubscriptionPublisher mapSourceToResponse = new SubscriptionPublisher(publisher, mapperFunction, keepOrdered, | ||
| throwable -> reactiveCtx.onCompleted(null, throwable)); |
There was a problem hiding this comment.
we pass in the call back here. Why?
We want the SubscriptionPublisher to be the implementation we pass back - we have tests for this.
So I changed SubscriptionPublisher internally to know when its finished
|
|
||
| called | ||
| throwable.message == "BANG" | ||
| } |
There was a problem hiding this comment.
Testing that the new helper works
| return t1 == t2 | ||
| } | ||
| return false | ||
| } |
There was a problem hiding this comment.
Just to make it easier to check large list of values for ordered things. Helpful with Instrumentation "step" testing
| ["a"], ["b"], ["c"], ["X"], ["e"], ["f"], ["g"]) | ||
| then: | ||
| !actual | ||
|
|
There was a problem hiding this comment.
Test thats the TestUtil helpers work
| ]) | ||
|
|
||
| // last of all it finishes | ||
| instrumentation.executionList.last == "end:reactive-results-defer" |
There was a problem hiding this comment.
Test that @defer publisher can tell us when they are finished
…tation callback - fixed tests
…lback-after-reactive-publishers-finish
…tation callback -null marked
| ]) | ||
|
|
||
| // last of all it finishes | ||
| TestUtil.last(instrumentation.executionList) == "end:reactive-results-defer" |
There was a problem hiding this comment.
Rather than test ALL the instrumentation steps again - we look at sub sections and make sure they are in order
This balances completeness with code readability / maintain ability
…lback-after-reactive-publishers-finish # Conflicts: # src/test/groovy/graphql/TestUtil.groovy # src/test/groovy/graphql/execution/SubscriptionExecutionStrategyTest.groovy # src/test/groovy/graphql/execution/instrumentation/InstrumentationTest.groovy
This adds Insrtrumentation support for reactive results - namely defer Publishers and Subscription Publisher.
When the Publisher is finished (throwable or not error) then the Instrumentation context is considered finished and called.
See #4083 for related code