一  什么是grpc

google出了一款分布式通讯框架:grpc。我想这也不是新的东西了,在13年的一个项目中,用在了数据层和业务端之间的通讯上,当时并没有觉得怎么样,因为wcf很轻松的也可以可以实现哪些功能。但是想在想一想,确实在某些场合,grpc比wcf要更好一点。第一就是比wcf要轻量级的多,第二,跨平台,他出了一款协议Protocol Buffers,来定义接口,然后使用工具去生成不同 的语言代码。而wcf我们也知道,跨平台使用soap协议,基于http,坏处就是慢。而基于tcp或者命名管道,又不跨平台。所以grpc非常适合某些特殊的场景中使用。尤其是他的消息交换是json,比wcf的xml轻量级很多。

二  配置说明

vs2017简单的安装几个nuget包:

为项目添加proto文件,查看工程文件

  <ItemGroup>
<Protobuf Include="proto\order.proto"
CompileOutputs="false" />
</ItemGroup>

CompileOutputs:这个配置属性意思就是不要编译进程序集

  <ItemGroup>
<Protobuf Include="**/*.proto" OutputDir="%(RelativePath)" CompileOutputs="false" />
</ItemGroup>
OutputDir :这个属性意思就很明显了,输出目录
 <ItemGroup>
<Protobuf Include="**/*.proto" OutputDir="%(RelativePath)"
CompileOutputs="false" GrpcServices="None" />
<Protobuf Update="**/hello/*.proto;**/bye/*.proto" GrpcServices="Both" />
</ItemGroup>
<Protobuf Update="**/hello/*.proto;**/bye/*.proto" GrpcServices="Both" /> 告诉插件只有这个节点配置的proto才进行更新,这是针对大一点的项目,不想让它生成整个项目的proto
GrpcServices是指生成客户端,还是服务端,还是两部分都生成。
 <ItemGroup>
<Protobuf Include="**/*.proto" OutputDir="%(RelativeDir)"
CompileOutputs="false" GrpcServices="None" />
</ItemGroup>

GrpcServices="None" 只生成message不生成services

  <ItemGroup>
<Protobuf Include="../**/*.proto" ProtoRoot=".."
OutputDir="%(RelativeDir)" CompileOutputs="false" />
</ItemGroup>

ProtoRoot 指定生成的代码导出的地方。

最新文章

  1. Yii ActiveRecord 的via和viaTable示例
  2. C++ 数字转换为string类型
  3. jenkins创建job不能用中文问题
  4. pthread_detach pthread_join pthread_create
  5. struts2与cookie实现自动登录和验证码验证
  6. Storm入门
  7. 【python】python支持中文变量,醉了
  8. 状压dp-poj-1170-Shopping Offers
  9. 【Android开发日记】第一个任务Android Service!Service靴+重力感应器+弹出窗口+保持执行
  10. Spring初始化ApplicationContext线程托管实际运用架构构思
  11. requests+selenium==requestium模块介绍
  12. mybatis bug之org.apache.ibatis.exceptions.PersistenceException:
  13. 虚拟机安装及ubuntu-16.04.3-desktop-amd64.iso映像文件的安装
  14. C\C++学习笔记 3
  15. 高级UI特效—用SVG码造一个精美的中国地图
  16. Hp电脑开机报错:no boot disk has been detected or the disk has failed
  17. Python基础(2)——列表、字典、数据运算
  18. 【模板】倍增+Floyd
  19. 随笔 -- NIO -- 相关 -- 系统概述
  20. iOS-本地的推送

热门文章

  1. 02 Spring框架 简单配置和三种bean的创建方式
  2. docker helloworld
  3. TOGAF和BABOK
  4. 每天一个Linux命令(54)chkconfig命令
  5. java Excel导入导出工具类
  6. 谷歌浏览器安装jsonview插件方法
  7. 开机启动顺序rc.local与chkconfig的不同
  8. space sniffer清理的空间
  9. 集群环境ssh免密码登录设置
  10. http 常见的错误码