Похожие чаты

Can I execute qarkus REST and gRPC in the same

project??

2 ответов

14 просмотров

What do you mean by "execute" here? I assume that you mean "can the same app handle both grpc and rest requests?". I never used quarkus, but I have a very good expertise in vertx. Quarkus uses vertx under the hood, it's basically vertx + DI + glue/sugar code to enhance and simplify vertx stuff + lots of integrations. If you put the question this way - "is it possible in vertx app to handle both rest and grpc requests" - then answer is yes. To do that in vertx, the key part is to set selector by content type, so all grpc requests go to grpc handler, and all the other requests - to the other route handlers. var grpcServer = GrpcIoServer.server(vertx) // .... register all handlers for grpc server var router = Router.router(vertx) router.route().consumes('application/grpc').handler { grpcHttpReq -> grpcServer.handle(grpcHttpReq) } router.route().handler { nonGrpcHttReq -> ....} Grpc requests are http2 requests that always have "content-type: application/grpc" header. That's the key part. Vertx documentation for this subject: https://vertx.io/docs/vertx-grpc/java/ Also, another obvious approach is to start two separate http servers on different ports. You can do that easily in vertx var grpcHttpSrv = vertx.createHttpServer(); var restHttpSrv = vertx.createHttpServer(); var grpcRouter = Router.create(vertx); var restRouter = ... // set them up separately grpcHttpSrv.listen(grpcPort); restSrv.listen(restPort); But at a glance, I highly doubt that quarkus can do that, and that there's a way that all that "glue/sugar code to enhance and simplify vertx stuff" quarkus code is prepared to distinguish between two separate servers under the hood. So if you figure out how to get to that router that is used under the hood of quarkus, AND if it's possible to customize these pieces, you should be able to do that. It may just happen that quarkus unconditionally registers grpc handler this way, without "content-type" selector router.route().handler { anyReq -> grpcServer.handle(anyReq) } If that's the case, you can't do anything about it. Quarkus documentation is total crap, unstructured pile of hello-world-ish how-to guides. I can't find anything about router quickly there. Hence, the answer is in the quarkus code itself. Also, there's a hint here: https://quarkus.io/guides/grpc-getting-started#different-grpc-implementations-types Another thing to take note as well is that Quarkus' gRPC support currently includes 3 different types of gRPC usage: - old Vert.x gRPC implementation with a separate gRPC server (default) - new Vert.x gRPC implementation on top of the existing HTTP server - xDS gRPC wrapper over grpc-java with a separate Netty based gRPC server If I understand it correctly, first approach is about runnting two separate http servers on different ports. Second is about having the same http server with "content-type: application/grpc" selector. And third one is again about a separate http server for grpc, but on the lowest level (netty). So based on this piece of documentation, it should be possible, and it feels that it's possible in all 3 kind of setups.

D- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта