Search code examples
protocol-buffers

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


I have two micro services. First service encodes messages using google protobuf (google docs) and sends to second one. Second one decodes this message and uses the data.

Now I need to add a field to this message object. If I do it at one side only will it break another side?

For example, if I add something to json this will break nothing. Is it really the same with google protobuf?


Solution

  • From the docs (see here: 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.