-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add support for Kotlin in Async #319
Conversation
Awesome! Thanks for driving this! |
Are you planning to convert this PR to "Ready to review status"? |
@mfateev Yes. My current priority is opentracing though. After preparing opentracing PR, I will polish this PR one more time and will open it for review. |
f98b904
to
bf6ca46
Compare
bf6ca46
to
c0e6914
Compare
* Functions.Func} implementation | ||
* @return promise on the return value of the asynchronous invocation of {@code func} | ||
*/ | ||
private static <R> Promise<R> execute(boolean temporalStub, Functions.Func<R> func) { |
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.
Can temporalStub
not be determined by inspecting func
?
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.
It can! but the point of this function is that we expected the func
already earlier and provide this as an input. It's a private function, not a part of the class API.
if (methodReferenceDisassemblyService == null) { | ||
throw new IllegalStateException( | ||
"Kotlin method reference is used with async. " | ||
+ "For Temporal to correctly support async invocation kotlin method references add temporal-kotlin to classpath"); |
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.
+ "For Temporal to correctly support async invocation kotlin method references add temporal-kotlin to classpath"); | |
+ "For Temporal to correctly support async invocation kotlin method references, add temporal-kotlin to classpath"); |
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 looks reasonable to me but I can't really claim to fully track all the weird reflection stuff going on. Adding some brief docstring explainers might be nice.
791974a
to
22d83c1
Compare
cc8f368
to
369c809
Compare
369c809
to
e370202
Compare
Previous behavior
Previously Async didn't handle method references on Temporal stubs coming from Kotlin correctly.
As the result, method references on Temporal stubs were treated as regular functions and executed as a new child thread of the workflow instead of just inline calls to an async stub.
There is a relevant post about this issue in an unrelated discussion: #537 (comment)
#Change
temporal-kotlin module has been added that provides support for correct temporal stubs detection inside Async if the method referenced is passed from kotlin code.
After merging this PR Kotlin users will have to add
io.temporal:temporal-kotlin
module to the classpath or they will get an exception trying to use Async.