分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

基于Ocelot的gRpcHttp网关

发布时间:2023-09-06 02:16责任编辑:傅花花关键词:暂无标签

什么是gRpcHttp网关

通俗的讲就是将gRpc提供的服务以rest api的形式提供出去,不需要再单独的写一个webapi去做这件事。

gRpcHttp网关好处

减少不必要代码,减少中间层提高通讯效率。

以前可能是这样

用了gRpc网关后是这样

gRpcHttp网关提供哪些功能

  • 可以直接加载proto生成的dll文件
  • 可以只需要proto文件,自动解析出proto文件所提供的model和service
  • 支持header转发
  • 支持gRpc的四种模式
  • 支持gRpc中间件
  • 支持swagger(开发中)
  • 支持proto和dll文件动态新增,不需要重启网关

Getting Started

  • 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 查看当前服务和方法

你还可以复制.proto文件到Examples.GrpcModels.dll to samples\OcelotGateway\bin\Debug\netcoreapp2.1\protos目录
查看http://localhost:5000/srv变化

Github

https://github.com/BuiltCloud/Ocelot.GrpcHttpGateway

基于Ocelot的gRpcHttp网关

原文地址:https://www.cnblogs.com/kingreatwill/p/9722963.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved