首页 > 解决方案 > grpc带rest作为网关有什么好处?

问题描述

像这里描述的那样,将 grpc 作为网关的 grpc 有什么好处 --> https://grpc.io/blog/coreos

由于 grpc-web 还不够成熟(如这里所述 --> https://docs.microsoft.com/en-us/aspnet/core/grpc/comparison?view=aspnetcore-3.0),因此交互很重要对于浏览器,我也可以使用 REST API 来解决所有问题。

标签: restgrpc

解决方案


REST and gRPC are both tools that fit different use cases. If you have a large enough project that would benefit from a microservice architecture, gRPC provides type safe inter-service communication, performance gains, and automatic server and client stub generation. Imagine never having to implement a HTTP client stub again, for me, that’s the best argument to use gRPC. For REST, there’s code generation tools like Swagger but they’re cumbersome and half of the spec file ends up being HTTP bloat, when I simply just want to call a function on a server. Of course, with gRPC you still need to implement a REST API assuming you need to support browser based clients—but this REST api will be fairly simple and will only have the concern of delegating to the correct gRPC microservices.


推荐阅读