Похожие чаты

Can I execute qarkus REST and gRPC in the same

project??

2 ответов

2 просмотра

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- Автор вопроса

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

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

Hey everyone! I won’t focus too much on what this person said (it’s clear they don’t understand the scope of what TF and TELOSX are achieving), but I’ll put it simply for thos...
Ana Ojeda
3
как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
Telos is at a pivotal moment. While ambitious projects like zkEVM and SNARKtor have shown promise, the delay in delivering EVM 2.0—a cornerstone of the ecosystem—is a growing ...
Trinidad
8
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
i have a small doubt i developed a rest API in put mapping (we use if more than one filed needs to be updated by user ) but concern is i am using dto class in that i am u...
Surya
6
Всем привет! Решаю 99 OCaml Problems и столкнулся со следующей проблемой (прошу палками не забивать, я OCaml практически не трогал до этого момента): open OUnit2 let create_...
К|/|pи/\/\ 6е3yглbIи
2
Except the wealthiest, people that buy crypto want to "cash out" at the end of the day, one way or another. Converting to fiat is craziness, converting to BTC is unwise. Hold ...
Erdelanax
2
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Hello guys, hope you can help me with a quick question. I've staked some ZIL using Atomic Wallet some while ago and wanted to claim my rewards and unstake it. Atomic Wallet sa...
Martin | #bornbrave
14
Карта сайта