基于Ocelot的gRpcHttp网关
什么是gRpcHttp网关
通俗的讲就是将gRpc提供的服务以rest api的形式提供出去,不需要再单独的写一个webapi去
做这件事。
gRpcHttp网关好处
减少不必要代码,减少中间层提高通讯效率。
以前可能是这样
文章图片
用了gRpc网关后是这样
文章图片
gRpcHttp网关提供哪些功能
- 可以直接加载proto生成的dll文件
- 可以只需要proto文件,自动解析出proto文件所提供的model和service
- 支持header转发
- 支持gRpc的四种模式
- 支持gRpc中间件
- 支持swagger(开发中)
- 支持proto和dll文件动态新增,不需要重启网关
- git clone https://github.com/BuiltCloud/Ocelot.GrpcHttpGateway.git
- cd Ocelot.GrpcHttpGateway/src
- cd samples\OcelotGateway and dotnet run
- cd samples\Examples.GrpcServer and dotnet run
- copy Examples.GrpcModels.dll to samples\OcelotGateway\bin\Debug\netcoreapp2.1\plugins
- curl http://localhost:5000/grpc/PLAYERSEARCH/SEARCHTEAM
- curl http://localhost:5000/grpc/PLAYERSEARCH/SearchPlayer_ServerStream
- curl http://localhost:5000/grpc/PLAYERSEARCH/SearchPlayer_ClientStream
- curl http://localhost:5000/grpc/PLAYERSEARCH/SearchPlayer_DuplexStream
- curl http://localhost:5000/srv 查看当前服务和方法
查看http://localhost:5000/srv变化
Github https://github.com/BuiltCloud/Ocelot.GrpcHttpGateway 相关文章:
- AspNetCore中使用Ocelot之 IdentityServer4
- Ocelot-基于.NET Core的开源网关实现
- .NET Core微服务之基于Ocelot+IdentityServer实现统一验证与授权
- Swagger如何访问Ocelot中带权限验证的API
- Ocelot.JwtAuthorize:一个基于网关的Jwt验证包
- .NET Core微服务之基于Ocelot实现API网关服务
- .NET Core微服务之基于Ocelot实现API网关服务(续)
- .NET微服务体系结构中为什么使用Ocelot实现API网关
- Ocelot简易教程(一)之Ocelot是什么
- Ocelot简易教程(二)之快速开始1
- Ocelot简易教程(二)之快速开始2
- Ocelot简易教程(三)之主要特性及路由详解
- Ocelot简易教程(四)之请求聚合以及服务发现
.NET社区新闻,深度好文,欢迎访问公众号文章汇总 http://www.csharpkit.com
【基于Ocelot的gRpcHttp网关】
文章图片
推荐阅读
- 热闹中的孤独
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- 放屁有这三个特征的,请注意啦!这说明你的身体毒素太多
- 一个人的旅行,三亚
- 布丽吉特,人生绝对的赢家
- 慢慢的美丽
- 尽力
- 一个小故事,我的思考。
- 家乡的那条小河
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量