grpc:gRPC Concepts
本文介绍一些主要的gRPC概念。
服务定义
gRPC支持4种方法:
1、Unary RPCs where the client sends a single request to the server and gets a single response back, just like a normal function call.
入参和返回值是一个普通的protocol buffer message。示例:
message HelloRequest {
string greeting = 1;
}
message HelloResponse {
string reply = 1;
}
service HelloService {
rpc SayHello (HelloRequest) returns (HelloResponse);
}
2、Server streaming RPCs where the client sends a request to the server and gets a stream to read a sequence of messages back. The client reads from the returned stream until there are no more messages. gRPC guarantees message ordering within an individual RPC call.
入参是一个普通的protocol buffer message,返回值是一个流式的message。示例:
service HelloService {
rpc SayHello (HelloRequest) returns (stream HelloResponse);
}
3、Client streaming RPCs where the client writes a sequence of messages and sends them to the server, again using a provided stream. Once the client has finished writing the messages, it waits for the server to read them and return its response. Again gRPC guarantees message ordering within an individual RPC call.
入参是一个流式的message,返回值是一个普通的message。示例:
service HelloService {
rpc SayHello (stream HelloRequest) returns (HelloResponse);
}
4、Bidirectional streaming RPCs where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved.
入参和返回值都是流式的message。示例:
service HelloService {
rpc SayHello (stream HelloRequest) returns (stream HelloResponse);
}
同步 VS 异步
同步方法、异步方法都有,根据需要选用。
grpc:gRPC Concepts的更多相关文章
- 带入gRPC:gRPC Streaming, Client and Server
带入gRPC:gRPC Streaming, Client and Server 原文地址:带入gRPC:gRPC Streaming, Client and Server 前言 本章节将介绍 gRP ...
- 带入gRPC:gRPC Deadlines
带入gRPC:gRPC Deadlines 原文地址:带入gRPC:gRPC Deadlines项目地址:https://github.com/EDDYCJY/go... 前言 在前面的章节中,已经介 ...
- gRPC:Google开源的基于HTTP/2和ProtoBuf的通用RPC框架
gRPC:Google开源的基于HTTP/2和ProtoBuf的通用RPC框架 gRPC:Google开源的基于HTTP/2和ProtoBuf的通用RPC框架 Google Guava官方教程(中文版 ...
- 基于HTTP/2和protobuf的RPC框架:GRPC
谷歌发布的首款基于HTTP/2和protobuf的RPC框架:GRPC Google 刚刚开源了grpc, 一个基于HTTP2 和 Protobuf 的高性能.开源.通用的RPC框架.Protobu ...
- grpc-gateway:grpc对外提供http服务的解决方案
我所在公司的项目是采用基于Restful的微服务架构,随着微服务之间的沟通越来越频繁,就希望可以做成用rpc来做内部的通讯,对外依然用Restful.于是就想到了google的grpc. 使用grpc ...
- grpc-gateway:grpc转换为http协议对外提供服务
我所在公司的项目是采用基于Restful的微服务架构,随着微服务之间的沟通越来越频繁,就希望可以做成用rpc来做内部的通讯,对外依然用Restful.于是就想到了google的grpc. 使用grpc ...
- 带入gRPC:对 RPC 方法做自定义认证
带入gRPC:对 RPC 方法做自定义认证 原文地址:带入gRPC:对 RPC 方法做自定义认证项目地址:https://github.com/EDDYCJY/go... 前言 在前面的章节中,我们介 ...
- 思考gRPC :为什么是HTTP/2
Introducing gRPC Support with NGINX 1.13.10 - NGINX https://www.nginx.com/blog/nginx-1-13-10-grpc/ 思 ...
- 跟我一起学Go系列:gRPC 入门必备
RPC 的定义这里就不再说,看文章的同学都是成熟的开发.gRPC 是 Google 开源的高性能跨语言的 RPC 方案,该框架的作者 Louis Ryan 阐述了设计这款框架的动机,有兴趣的同学可以看 ...
随机推荐
- python基础--面向对象之多态
# 多态是指一类事物有多种行态, # 例如:动物有多种形态:人,狗,猫 # 他们有一些共同的特征:吃,喝,拉,撒 # 多态性是指在不考虑实例类型的情况下使用实例 # 对同一事物不同的类,对象有不同的响 ...
- [Vuejs] Vue解决代理设置导致浏览器Session丢失的问题
以下是会造成Session丢失的代理: proxyTable: { '/proxyApi': { target: 'http://111.18.149.215:8080/WRSOCXSystem/ht ...
- navicat连接 mysql报错1251解决方案
转自:https://blog.csdn.net/XDMFC/article/details/80263215 好不容易安装好mysql,但又出现了mysql客户端版本太低的问题.根据参考的这篇博客, ...
- spring boot-6.profile 多环境支持
在正式项目中一般都会区分多个环境,一般至少分为开发环境,测试生产环境,生产环境,实际可能会有更加精细的区分,针对不同的环境,项目的配置可能需要切换,spring boot 提供了很方便的环境切换方式. ...
- keepalived 容器在宿主机重启后无法启动问题:报错:daemon is already running
初步猜测原因是:keepalived容器内的keepalived.pid文件在keepalived容器非正常退出时,没有正确删除,造成第二次启动时容器检查到pid文件已经存在,认为该进程已经存在,因为 ...
- css overflow规定元素溢出框将会发生什么
- hugo搭建个人博客
本地先安装git 1. 下载hugo,并配置好环境变量 我这里win7 64位,选择该版本下载 将解压后的hugo.exe,配置到环境变量中,如下图所示表明配置成功 hugo version 2. 生 ...
- Maven出错的问题处理
1:使用Maven部署dubbox.jar包到maven本地仓库 由于Dubbox的jar包并没有部署到Maven的中央仓库中,大家在Maven的中央仓库中可以查找到Dubbo的最终版本是2.5.3 ...
- Android应用安全开发之源码安全
Android应用安全开发之源码安全 gh0stbo · 2016/01/21 10:24 0x00 简介 Android apk很容易通过逆向工程进行反编译,从而是其代码完全暴露给攻击者,使apk面 ...
- String与C风格字符串转换
String字符串转换为C风格字符串需要利用string类的成员函数c_str().而C风格字符串转换转换为string字符串可以直接利用运算符=.首先介绍c_str()函数原型: const val ...