Protobuf向后兼容性以及Proto3与Proto2 [英] Protobuf backward compatibility and proto3 vs proto2

查看:1530
本文介绍了Protobuf向后兼容性以及Proto3与Proto2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Protobuf的卖点之一是向后兼容,即开发人员可以发展格式,而老客户仍然可以使用它.

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

现在有了新的Protobuf版本proto3,IDL语言本身不兼容诸如optionsrequired放在其中,新的enuns语法,无扩展性之类的东西.

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.

这是否意味着使用proto3无法产生较旧的proto2也会读取/理解的二进制文件?

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

这就像您必须继续使用proto2.如果您开始使用proto3,则无法与较旧的系统通信,或者必须重写,重新编译所有这些.proto 首先是兼容性中断.

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.

推荐答案

是的,如果您的某些系统基于proto2,则最好继续使用proto2.我认为proto3没有引入许多新功能,并且大多数库将继续支持proto2.

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.

但是,wire格式几乎是兼容的.只要标签号相同,编码就保持相同.必需/可选说明符不影响编码,它们只是在解码后执行的检查.

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.

这篇关于Protobuf向后兼容性以及Proto3与Proto2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆