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 阐述了设计这款框架的动机,有兴趣的同学可以看 ...
随机推荐
- mybati代码生成器 mybatis-generator
Mybatis代码生成器,用于快速生成代码 代码 https://github.com/wangxinforme/mybatis-generator
- 洛谷 P1134 阶乘问题 题解
题面 很裸的边取模边乘.注意因为进位的原因模数应该比较大: 另外,这道题是一道标准的分块打表例题(那样的话数据就可以更大了),可以用来练习分块打表: #include<bits/stdc++.h ...
- [Codeforces 1245D] Shichikuji and Power Grid (最小生成树)
[Codeforces 1245D] Shichikuji and Power Grid (最小生成树) 题面 有n个城市,坐标为\((x_i,y_i)\),还有两个系数\(c_i,k_i\).在每个 ...
- 创建一个py文件并运行
在 Linux 中,可以直接用vim 或者 vi 来编辑一个 python 文件 vim hello.py 进入编辑页面 #coding:utf-8 print("你好") (因为 ...
- PythonDay10
第十章函数进阶 今日内容 函数的参数 动态参数 动态接收位置参数 动态接收关键字参数 函数的注释 名称空间 函数的嵌套 global.nonlocal global的宗旨 nonlocal宗旨 1.函 ...
- 重写移动端滚动条[iScroll.js核心代码]
最近写组件库的时后,发现这个滚动条是真的丑啊,决定重新撸一个滚动条: 首先咱们回顾一下移动端浏览器滚动条特性: 滚动条在开始滚动时渐显,滚动结束后渐隐 滚动条不占内容区宽度,悬浮固定 滚动条高度(深灰 ...
- BZOJ 3189. [Coci2011]Slika
传送门 有回档操作,考虑离线,这样就知道最终的操作序列了 发现前面的操作会被后面覆盖,干脆直接从后往前操作,如果一个位置以前染色过了那就不用再染色 所以我们可以用 $n$ 个链表维护 $n$ 个行,操 ...
- NlData初学者开发篇(ORM)
一, 简介:NlData是一个个人开发的ORM,为了学习而学习,是基于表达式实现的一个ORM 二,先简单介绍使用,如下,配置是统一接口 NlClient client = new NlClient(n ...
- 如何写一个 Burp 插件
Burp 是 Web 安全测试中不可或缺的神器.每一个师傅的电脑里面应该都有一个 Burp.同时 Burp 和很多其他神器一样,它也支持插件.但是目前总体来说网上 Burp 插件开发的资料不是特别特别 ...
- 如何使用前端分页框架bootstrap paginator
前端分页框架bootstrap paginator用于web前端页面快速实现美观大方的翻页功能.在实现交互良好的页面翻页功能时,往往还需要配合使用后端分页框架pagehelper.pagehelper ...