Protobuf backward compatibility and proto3 vs proto2

风格不统一 提交于 2019-12-08 00:11:46

问题


One of selling points of Protobuf was backward compatibility, i.e. developers can evolve format, and older clients can still use it.

Now with new Protobuf version called proto3, the IDL language itself is not compatible as such things as options, required where dropped, new syntax for enuns, no extention.

Does it mean that using proto3 there's no way to produce binary that older proto2 would read/understand also?

It is like you have to continue to use proto2. If you start using proto3, you can't talk to older systems, or have to rewrite, recompile all those .protos That is compatibility break in the first place.


回答1:


Yes, if some of your systems are proto2 based, it is probably best to keep using proto2. In my opinion, proto3 does not introduce many new features and most libraries will continue supporting proto2.

However, the wire format is mostly compatible. As long as the tag number is the same, the encoding remains the same. The required/optional specifiers do not affect the encoding, they are only checks that are performed after decoding.



来源:https://stackoverflow.com/questions/40680273/protobuf-backward-compatibility-and-proto3-vs-proto2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!