英文:
gRPC and schema evolution guarantees?
问题
我正在评估使用 gRPC。关于与 'schema evolution' 的兼容性问题,我确实找到了信息,即 gRPC 用于数据序列化的协议缓冲区具有一种格式,使得不同版本的 protobuf 格式数据可以保持兼容,只要模式的演变允许。
但这并不告诉我,无论模式的其余部分如何变化,两个 gRPC 客户端/服务器的两个迭代是否能够交换未在模式中更改的命令?
是否可以保证 gRPC 的较早生成的客户端或服务器代码始终能够使用与模式文件中未更改的命令来启动/回答与对话方生成的更近期的模式代码的交互,假设没有其他破坏性的变化,比如不向后兼容的 gRPC 版本更改?
英文:
I am evaluating using gRPC. On the subject of compatibility with 'schema evolution', i did find the information that protocol buffers, which are exchanged by gRPC for data serialization, have a format such that different evolutions of a data in protobuf format can stay compatible, as long as the schemas evolution allows it.
But that does not tell me wether two iterations of a gRPC client/server will be able to exchange a command that did not change in the schema, regardless of the changes in the rest of the schema?
Does gRPC quarantee that an older generated version of a client or server code will always be able to launch/answer a command that has not changed in the schema file, with any more recent schema generated code on the interlocutor side, reglardless of the rest of the schema? (Assuming no other breaking changes like a non backward compatible gRPC version change)
答案1
得分: 4
gRPC 具有兼容性,只要满足以下条件:
- proto包、服务名称和方法名称不变
- proto请求和响应消息仍然兼容
- 请求和响应消息的基数(一元 vs 流式)保持不变
可以随意添加新的服务和方法,不会影响现有方法的兼容性。这个话题没有太多讨论,因为大多数人都会预期这些限制。
实际上,在更改基数方面有一些余地,因为一元编码与流式编码在传输时是相同的,但通常最好假设不能更改基数,而是添加一个新方法。
这个话题在随时间修改gRPC服务讨论中(提供PDF幻灯片和YouTube链接)。需要注意的是,这些幻灯片并不是独立的文档。
英文:
gRPC has compatibility for a method as long as:
- the proto package, service name, and method name is unchanged
- the proto request and response messages are still compatible
- the cardinality (unary vs streaming) of the request and response message remains unchanged
New services and methods can be added at will and not impact compatibility of preexisting methods. This doesn't get discussed much because those restrictions are mostly what people would expect.
There is actually some wiggle room in changing cardinality as unary is encoded the same as streaming on-the-wire, but it's generally just better to assume you can't change cardinality and add a new method instead.
This topic is discussed in the Modifying gRPC Services over Time talk (PDF slides and Youtube links available). I'll note that the slides are not intended to stand alone.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论