-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
WebSockets Next: add support for Kotlin suspend functions #41760
WebSockets Next: add support for Kotlin suspend functions #41760
Conversation
This commit changes the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Looks good to me, but let's wait @mkouba's review.
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 think that we should update the WS next reference guide as well.
...-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java
Show resolved
Hide resolved
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir> | ||
<sourceDir>${project.basedir}/src/main/java</sourceDir> |
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.
Why do we use the kotlin-maven-plugin
to compile the java sources?
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.
No idea, honestly. This is how Kotlin Maven plugin is documented (see here) and it's also what we do elsewhere.
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.
Hehe ok. But in our case we don't have kotlin code in src/main/kotlin
, or? It's only used in tests. But if we do the same elsewhere 🤷
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.
Correct, we only have Kotlin tests. I figured I could also add Kotlin tests to integration-tests
to make the setup simpler, but not sure...
...ts-next/kotlin/src/main/kotlin/io/quarkus/websockets/next/runtime/kotlin/CoroutineInvoker.kt
Show resolved
Hide resolved
...-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java
Show resolved
Hide resolved
...ts-next/kotlin/src/main/kotlin/io/quarkus/websockets/next/runtime/kotlin/CoroutineInvoker.kt
Show resolved
Hide resolved
Good point, let me fix that! |
Kotlin `suspend` functions are treated like Java methods that return `Uni`. That is, they are considered non-blocking. The implementation uses CDI method invokers (to avoid custom bytecode generation), which actually convert the `suspend` function result into a `Uni` under the hood. With this commit, only single-shot `suspend` functions are supported; `suspend` functions returning `Flow` are not supported yet.
5e4b88f
to
2517290
Compare
Done. Also rebased and force-pushed. |
Status for workflow
|
Status for workflow
|
🙈 The PR is closed and the preview is expired. |
Kotlin
suspend
functions are treated like Java methods that returnUni
. That is, they are considered non-blocking. The implementation uses CDI method invokers (to avoid custom bytecode generation), which actually convert thesuspend
function result into aUni
under the hood.With this commit, only single-shot
suspend
functions are supported;suspend
functions returningFlow
are not supported yet.Fixes #40325