Skip to content
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

grpc - added grpc transcoding feature #40254

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zZHorizonZz
Copy link

@zZHorizonZz zZHorizonZz commented Apr 24, 2024

This pull request introduces grpc transcoding functionality, extending API accessibility by allowing grpc services to be called via HTTP requests as proposed here #25837. This implementation follows grpc transcoding described by Google Cloud grpc transcoding documentation, as I was not able to find If there is currently official grpc standard for this feature.

Example Usage:

// The greeting service definition.
service Greeter {
 // Simple path
 rpc SimplePath (HelloRequest) returns (HelloReply) {
  option (google.api.http) = {
   post: "/v1/simple"
   body: "*"
  };
 }

This configuration will enable quarkus to expose a new HTTP route at /v1/simple. HTTP requests to this route will be translated into calls to the underlying SimplePath grpc method. More detailed description can be seen here.

(Sorry for the previous PR. I had some trouble squashing commits, and after my force push, the bot added almost all of the labels)

@quarkus-bot quarkus-bot bot added the area/grpc gRPC label Apr 24, 2024
@zZHorizonZz zZHorizonZz marked this pull request as ready for review April 25, 2024 09:25

This comment has been minimized.

Copy link

github-actions bot commented Apr 25, 2024

🎊 PR Preview 79af515 has been successfully built and deployed to https://quarkus-pr-main-40254-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Author

@zZHorizonZz zZHorizonZz Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why these changes are here. I think when I ran optimize imports on the entire gRPC folder, it might be the cause. However, the changes might improve the code by removing unnecessary spaces and tabs, so I think this could be kept since I don't think any formatting is done on js by quarkus build anyway.

This comment has been minimized.

This comment has been minimized.

@gsmet gsmet requested review from cescoffier and alesj April 26, 2024 15:28

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

extensions/grpc/api/pom.xml Outdated Show resolved Hide resolved
@alesj
Copy link
Contributor

alesj commented Apr 29, 2024

@zZHorizonZz does plain gRPC also work along with this transcoding? Both old io.grpc and new Vert.x gRPC?
Do the tests cover this?

@zZHorizonZz
Copy link
Author

@zZHorizonZz does plain gRPC also work along with this transcoding? Both old io.grpc and new Vert.x gRPC? Do the tests cover this?

Do you mean if a separate server is on? Honestly, I haven't tested that specifically since I forgot about that (I will try to add some tests for it). However, basic gRPC with a separate server turned off works properly you can see that in the HelloWorldTranscodingEndpointTest where it calls the endpoint, and that then calls the client. It's similar to the other gRPC integration tests.

@alesj
Copy link
Contributor

alesj commented Apr 29, 2024

If you could add test(s) for all flavors (old2new, new2old, new2new, old2old) that would be good / nice as well.
So we make sure both things can co-exist.

But on another note, I feel as having a whole new gRPC server is a bit too much ... can't this just be a route to the existing new Vert.x gRPC server?

@zZHorizonZz
Copy link
Author

zZHorizonZz commented Apr 29, 2024

Now that I think about it, since I copied the grpc-vertx integration tests and mostly left the application.properties file the same. My question is when running JVM tests goal, does it run profiles that are specified in properties file? Are they specified somewhere? The properties file includes vertx, n2o, and o2n profiles, which (if used) should test everything with the separate server both on and off.

@alesj
Copy link
Contributor

alesj commented Apr 29, 2024

My question is when running JVM tests goal, does it run profiles that are specified in properties file? Are they specified somewhere?

The test then needs to have this profile enabled, see existing tests that have this.
You have a base test, and then separate tests with certain profiles:

@QuarkusTest
@TestProfile(N2OGRPCTestProfile.class)
class N2OLegacyHelloGrpcServiceTest extends LegacyHelloGrpcServiceTestBase {
}

@zZHorizonZz
Copy link
Author

zZHorizonZz commented Apr 29, 2024

But on another note, I feel as having a whole new gRPC server is a bit too much ... can't this just be a route to the existing new Vert.x gRPC server?

I wanted to reuse as much as possible from the Vert.x gRPC implementation, but as I got further I started running into issues. It comes down pretty much to decoding and encoding. Basically GrpcServerImpl creates a GrpcServerRequestImpl and uses the GrpcMessageDecoder and GrpcMessageEncoder for its parameters, like this:

new MethodCallHandler<>(methodDesc, GrpcMessageDecoder.unmarshaller(methodDesc.getRequestMarshaller()), GrpcMessageEncoder.marshaller(methodDesc.getResponseMarshaller()), handler));

And then these parameters are passed to GrpcServerRequestImpl like this:

new GrpcServerRequestImpl<>(httpRequest, method.messageDecoder, method.messageEncoder, methodCall);

The problem is that I can't directly use these decoders and encoders for gRPC and decode and encode json with them. Furthermore, I need to merge route and query parameters into the payload, which is done by GrpcTranscodingRequest.

Copy link

quarkus-bot bot commented Apr 29, 2024

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit 5c74729.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

⚠️ There are other workflow runs running, you probably need to wait for their status before merging.

Copy link

quarkus-bot bot commented Apr 29, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 5c74729.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
MicroProfile TCKs Tests Verify Failures Logs Raw logs 🔍

Full information is available in the Build summary check run.
You can consult the Develocity build scans.

Failures

⚙️ MicroProfile TCKs Tests #

- Failing: tcks/microprofile-opentelemetry 

📦 tcks/microprofile-opentelemetry

org.eclipse.microprofile.telemetry.tracing.tck.async.JaxRsClientAsyncTest.testIntegrationWithJaxRsClientAsync - History - More details - Source on GitHub

java.util.concurrent.RejectedExecutionException: event executor terminated
	at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:934)
	at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:351)
	at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:344)
	at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:836)
	at io.netty.util.concurrent.SingleThreadEventExecutor.execute0(SingleThreadEventExecutor.java:827)
	at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:817)
	at io.vertx.core.impl.EventLoopExecutor.execute(EventLoopExecutor.java:35)

@zZHorizonZz
Copy link
Author

If you could add test(s) for all flavors (old2new, new2old, new2new, old2old) that would be good / nice as well.

@alesj I'm a bit confused about what you meant with old2new, new2old, etc as there isn't really anything that I could categorize as "old" there are only new things from my point of view.

@alesj
Copy link
Contributor

alesj commented May 10, 2024

If you could add test(s) for all flavors (old2new, new2old, new2new, old2old) that would be good / nice as well.

@alesj I'm a bit confused about what you meant with old2new, new2old, etc as there isn't really anything that I could categorize as "old" there are only new things from my point of view.

We have tests that check all 4 combinations - matrix between io.grpc and our Vert.x gRPC.

But this won't change the fact that we need to get this into Vert.x, and not into Quarkus gRPC,
as there really should not be 2 servers running to handle this -- only a single one, capable of handling plain gRPC and transcoding as well.

@zZHorizonZz
Copy link
Author

But this won't change the fact that we need to get this into Vert.x, and not into Quarkus gRPC,
as there really should not be 2 servers running to handle this -- only a single one, capable of handling plain gRPC and transcoding as well.

I agree with that. I will try to open an issue on vertx-grpc and try to figure out how this could be done.

@zZHorizonZz zZHorizonZz marked this pull request as draft May 10, 2024 09:47
Copy link
Member

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that most of this code should to into Vert.x gRPC server and not in Quarkus.
Duplicating the gRPC server is going to be a non-meaningless maintenance burden. We already have the legacy and old one to maintain, having a third might not be the best idea.

@cescoffier cescoffier added the triage/on-ice Frozen until external concerns are resolved label Dec 16, 2024
@cescoffier
Copy link
Member

Marking it as on-ice. The feature is super interesting, but we need to find a proper way to implement it. We may need to tweak things in Vert.x to avoid code duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

3 participants