本文介绍一些主要的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的更多相关文章

  1. 带入gRPC:gRPC Streaming, Client and Server

    带入gRPC:gRPC Streaming, Client and Server 原文地址:带入gRPC:gRPC Streaming, Client and Server 前言 本章节将介绍 gRP ...

  2. 带入gRPC:gRPC Deadlines

    带入gRPC:gRPC Deadlines 原文地址:带入gRPC:gRPC Deadlines项目地址:https://github.com/EDDYCJY/go... 前言 在前面的章节中,已经介 ...

  3. gRPC:Google开源的基于HTTP/2和ProtoBuf的通用RPC框架

    gRPC:Google开源的基于HTTP/2和ProtoBuf的通用RPC框架 gRPC:Google开源的基于HTTP/2和ProtoBuf的通用RPC框架 Google Guava官方教程(中文版 ...

  4. 基于HTTP/2和protobuf的RPC框架:GRPC

    谷歌发布的首款基于HTTP/2和protobuf的RPC框架:GRPC Google 刚刚开源了grpc,  一个基于HTTP2 和 Protobuf 的高性能.开源.通用的RPC框架.Protobu ...

  5. grpc-gateway:grpc对外提供http服务的解决方案

    我所在公司的项目是采用基于Restful的微服务架构,随着微服务之间的沟通越来越频繁,就希望可以做成用rpc来做内部的通讯,对外依然用Restful.于是就想到了google的grpc. 使用grpc ...

  6. grpc-gateway:grpc转换为http协议对外提供服务

    我所在公司的项目是采用基于Restful的微服务架构,随着微服务之间的沟通越来越频繁,就希望可以做成用rpc来做内部的通讯,对外依然用Restful.于是就想到了google的grpc. 使用grpc ...

  7. 带入gRPC:对 RPC 方法做自定义认证

    带入gRPC:对 RPC 方法做自定义认证 原文地址:带入gRPC:对 RPC 方法做自定义认证项目地址:https://github.com/EDDYCJY/go... 前言 在前面的章节中,我们介 ...

  8. 思考gRPC :为什么是HTTP/2

    Introducing gRPC Support with NGINX 1.13.10 - NGINX https://www.nginx.com/blog/nginx-1-13-10-grpc/ 思 ...

  9. 跟我一起学Go系列:gRPC 入门必备

    RPC 的定义这里就不再说,看文章的同学都是成熟的开发.gRPC 是 Google 开源的高性能跨语言的 RPC 方案,该框架的作者 Louis Ryan 阐述了设计这款框架的动机,有兴趣的同学可以看 ...

随机推荐

  1. selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH

    问题,找不到’geckodriver’ 的环境path,解决方案 下载geckodriver.exe 放到Firefox的安装目录下,如:(D:\火狐\Mozilla Firefox): 将火狐安装目 ...

  2. Spring JdbcTemplate 和 NamedParameterJdbcTemplate 使用

    1.简单介绍 DAO层 的一般使用常见的是MyBatis 和 Hibernate,但是Hibernate是重量级的,而且学习成本较高,Mybatis 需要编写大量配置文件及接口文件,对于简单的项目应用 ...

  3. AKKA学习(二) 未完

    Actor调用 从上面的例子中,我们可以大概的对AKKA在JAVA中的使用有一个全局的概念.这里我们在稍微细致的讲解一下. 在JAVA中使用AKKA进行开发主要有这几个步骤: 定义消息模型. 创建Ac ...

  4. 在(U)EFI环境下重装Grub2

    本文链接:https://blog.csdn.net/ytingone/article/details/59209526 前段时间重装了系统,导致Grub2的引导消失,所以现在需要进行恢复. 首先需要 ...

  5. Homebrew学习(一)之初认识

    Homebrew Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装.卸载.更新.查看.搜索等很多实用的功能.简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,会 ...

  6. 断言(assert)

    断言是编程术语,表示为一些布尔表达式,程序员相信在程序中的某个特定点该表达式值为真,可以在任何时候启用和禁用断言验证,因此可以在测试时启用断言而在部署时禁用断言. 简单点说,断言指的就是,将结果判断说 ...

  7. Linux常用命令及Shell的简单介绍

    一.linux命令   1.查看指令的参数搭配: man 指令名称   2.基础指令 ls  列出当前目录下的所有文档的名称(文档指的是文件和文件夹) 常用参数搭配: ls -l 列出文档详细信息 l ...

  8. 经典解压缩软件 WinRAR 5.80 sc 汉化去广告版

    目录 1. 按 2. 提醒 3. 下载地址 1. 按 WinRAR拥有全球超过五千万的用户,是目前最受欢迎的压缩软件, 没有比它更加好的方法来实现高效安全的文件传输,减少电子邮件传输时间,或是迅速压缩 ...

  9. tf.get_variable函数的使用

    tf.get_variable(name,  shape, initializer): name就是变量的名称,shape是变量的维度,initializer是变量初始化的方式,初始化的方式有以下几种 ...

  10. laravel 学习之第一章

    LTS : long time support. download url : http://www.golaravel.com/download/ 第一篇 目录介绍: ​ resource:包含了原 ...