-
Notifications
You must be signed in to change notification settings - Fork 136
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
Generate Kotlin gRPC Stubs #169
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pedro Tôrres <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #169 +/- ##
============================================
- Coverage 88.26% 88.16% -0.11%
+ Complexity 298 297 -1
============================================
Files 31 31
Lines 980 980
Branches 78 78
============================================
- Hits 865 864 -1
Misses 85 85
- Partials 30 31 +1
Continue to review full report at Codecov.
|
Hi, I will test it in Envoy-Control and check if it works and if it does i'll review it and merge it. |
Hi @slonka! Were you able to verify this works? |
<dependency> | ||
<groupId>com.google.protobuf</groupId> | ||
<artifactId>protobuf-java</artifactId> | ||
<version>${protobuf.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jetbrains.kotlinx</groupId> | ||
<artifactId>kotlinx-coroutines-core</artifactId> |
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 need coroutines for that?
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.
In Kotlin, the base implementations of gRPC services use coroutines to deal with blocking operations. This way, developers don't need to deal with StreamObserver
s like they have to do in Java and just implement a suspend
function that returns the object directly.
Java implementation:
https://github.com/grpc/grpc-java/blob/c540229d79c6d8d29da34d22c3c5add2138bdc87/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java#L81-L89
Kotlin implementation:
https://github.com/grpc/grpc-kotlin/blob/b7d06483bf597cd4a10e3ed2ef52b21ca95c80ad/examples/server/src/main/kotlin/io/grpc/examples/helloworld/HelloWorldServer.kt#L48-L53
Hi @t0rr3sp3dr0 - sorry for the delay. I've run into a bit of a problem, after leaving Allegro I no longer can release SNAPSHOTs of java-control-plane. I'm getting |
@rulex123 and @onemanbucket, are you able to take a look on this PR? |
@rulex123 and @onemanbucket, sorry to ping you again, but it seems you are the only ones contributing to this repository at the moment. I even sent a message on the control-plane-dev channel on Slack to find other maintainers, but got no answer (https://envoyproxy.slack.com/archives/C7LDJTM6Z/p1644537207034489). I would appreciate if you could review this patch. |
Hi everyone! Sorry to tag all the project maintainers here, but I've been trying to get someone to review this PR for over 9 months now and I've had no success so far. If someone can take a look here, I'd really appreciate it! 🙂 @Automaat @Ferdudas97 @b-hoyt @chemicL @gawarz @joeyb @kukulam-allegro @lukidzi @mpuncel @ramaraochavali @slonka @snowp |
hello, is any update on this PR/item? I'd really appreciate it as well. |
This patch modifies build configuration files to generate gRPC Stubs for Kotlin and place them inside the built artifact. The changes were based on official tutorials on how to configure maven-protobuf-plugin to generate Kotlin gRPC Stubs (https://github.com/grpc/grpc-kotlin/tree/master/compiler) and how to build Kotlin with Maven (https://kotlinlang.org/docs/maven.html).
In the built JAR, for each ServiceGrpc class generated from a gRPC service definition on proto files, a new class called ServiceGrpcKt is introduced with the Kotlin interface. I've tested it on a Java-only project to make sure it doesn't cause any problem.
The built artifact is available on JitPack: https://jitpack.io/#t0rr3sp3dr0/java-control-plane/3bd90153d9.
Closes #168