Google protobuf:如果我从一侧添加字段,它会破坏另一侧吗?

Google protobuf: if I add field from one side will it break another one?

我有两个微服务。第一个服务使用 google protobuf (google docs) 对消息进行编码并发送到第二个服务。第二个解码此消息并使用数据。

现在我需要向这个消息对象添加一个字段。如果我只在一侧做,它会破坏另一侧吗?

例如,如果我向 json 添加一些内容,这不会破坏任何内容。 google protobuf真的一样吗?

来自文档(参见此处:https://developers.google.com/protocol-buffers/docs/overview):

You can add new fields to your message formats without breaking backwards-compatibility; old binaries simply ignore the new field when parsing. So if you have a communications protocol that uses protocol buffers as its data format, you can extend your protocol without having to worry about breaking existing code.

引自 Goole Protobuf 文档关于扩展 Protobuf 从 here:

you must not change the tag numbers of any existing fields.
you must not add or delete any required fields.
you may delete optional or repeated fields.
you may add new optional or repeated fields but you must use fresh tag numbers (i.e. tag numbers that were never used in this protocol buffer, not even by deleted fields).

在您的情况下,如果您在一侧的更改没有违反上述任何规则,则不会破坏另一侧。