gf icon indicating copy to clipboard operation
gf copied to clipboard

grpc-gateway: Mr. Qiang, there is one less grpc gateway for microservices

Open wisonlau opened this issue 1 year ago • 14 comments

Description

goframe框架后续有打算搞个grpc网关么,如果没有网关的后,搞微服务,下面的子模块要同时写接收http和grpc请求,有点麻烦.

gRPC 网关是一个 HTTP 服务器,它将 RESTful API 转换为 gRPC 请求,然后将 gRPC 响应转换为 RESTful API。大致流程如下: 从 proto 文件中解析出 gRPC 服务的定义。 从 配置文件中解析出 gRPC 服务的 HTTP 映射规则。 根据 gRPC 服务的定义和 HTTP 映射规则,生成 gRPC 服务的 HTTP 处理器。 启动 HTTP 服务器,处理 HTTP 请求。 将 HTTP 请求转换为 gRPC 请求。 将 gRPC 响应转换为 HTTP 响应。 返回 HTTP 响应。

Additional

No response

wisonlau avatar Aug 22 '24 08:08 wisonlau

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Description

Does the goframe framework plan to build a grpc gateway in the future? If there is no gateway and microservices are built, the following sub-modules must be written to receive http and grpc requests at the same time, which is a bit troublesome.

A gRPC gateway is an HTTP server that converts RESTful APIs into gRPC requests and then converts gRPC responses into RESTful APIs. The general process is as follows: Parse the gRPC service definition from the proto file. Parse the HTTP mapping rules of the gRPC service from the configuration file. Generate the HTTP handler of the gRPC service based on the gRPC service definition and HTTP mapping rules. Start the HTTP server and handle HTTP requests. Convert HTTP requests to gRPC requests. Convert gRPC responses to HTTP responses. Return HTTP response.

Additional

No response

Issues-translate-bot avatar Aug 22 '24 08:08 Issues-translate-bot

同一个 HTTP 请求可能需要若干个 gRPC 拼接起来,HTTP 网关不属于框架的职责范畴

oldme-git avatar Aug 23 '24 07:08 oldme-git

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The same HTTP request may require several gRPCs to be spliced ​​together. HTTP gateways are not within the scope of the framework's responsibilities.

Issues-translate-bot avatar Aug 23 '24 07:08 Issues-translate-bot

同一个 HTTP 请求可能需要若干个 gRPC 拼接起来,HTTP 网关不属于框架的职责范畴

你没理解我要干什么.

image

看这个图,里面的 用户, 商品,...这些都是单独的服务,是单独部署和启动的.只不过这几个服务的代码放一起,目前是一些公共的代码可以共用. 如果不搞个网关,怎么搞微服务,那鉴权那些不是每个服务都要写么?

wisonlau avatar Aug 23 '24 10:08 wisonlau

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The same HTTP request may require several gRPCs to be spliced ​​together, and the HTTP gateway is not within the scope of the framework's responsibilities.

You don't understand what I want to do.

image

Look at this picture, the users, products,... these are all separate services, deployed and started separately. However, the codes of these services are put together, and currently some common codes can be shared.

Issues-translate-bot avatar Aug 23 '24 10:08 Issues-translate-bot

@gqcn 当客户端不支持 gRPC 协议时,或者需要将 gRPC 服务暴露给 Web 应用程序时,便捷的生成 RESTful API 转换为 gRPC 的相关函数,参考 go-zore。 备注:RESTful API 转换为 gRPC 不够灵活,应该考虑更灵活的方式

oldme-git avatar Aug 25 '24 03:08 oldme-git

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn When the client does not support the gRPC protocol, or when the gRPC service needs to be exposed to a Web application, it is convenient to generate RESTful API conversion functions related to gRPC. Please refer to [go-zore](https://go-zero. dev/docs/tutorials/gateway/grpc)

Issues-translate-bot avatar Aug 25 '24 03:08 Issues-translate-bot

除了做http转grpc,还有权限验证,请求拦截... 这些功能

wisonlau avatar Aug 25 '24 13:08 wisonlau

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


In addition to converting http to grpc, there are also permission verification, request interception... these functions

Issues-translate-bot avatar Aug 25 '24 13:08 Issues-translate-bot

看这个微服务框架的网关就不错,如果可以集成进来成为一体的话. https://github.com/go-kratos/gateway/

wisonlau avatar Sep 10 '24 08:09 wisonlau

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It would be good to look at the gateway of this microservice framework, if it can be integrated into one. https://github.com/go-kratos/gateway/

Issues-translate-bot avatar Sep 10 '24 08:09 Issues-translate-bot

@wisonlau @oldme-git 你好,由于grpc相关的开源网关已经有比较多现成的,考虑到生态共建,这块没有太大重复建设的必要性,因此目前框架暂无开发grpc网关的计划。这块网关的开发其实也比较简单,如果有感兴趣的朋友也可以参与社区的贡献。目前框架的发展精力更偏向于组件建设和工程管理方面。

gqcn avatar Oct 05 '24 06:10 gqcn

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@wisonlau @oldme-git Hello, since there are many ready-made open source gateways related to grpc, the framework currently has no plans to develop grpc gateway. The development of this gateway is actually relatively simple. If you are interested, you can also participate in community contributions. At present, the development energy of the framework is more focused on component construction and project management.

Issues-translate-bot avatar Oct 05 '24 06:10 Issues-translate-bot

Hello @wisonlau. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it! 你好 @wisonlau。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。

github-actions[bot] avatar Oct 05 '24 06:10 github-actions[bot]