3 ms·
If your protobufs (and their producer/consumers) are short-living, just remove the "required" field from your servers and clients at the same time. The "requir
by yongjik 12y ago
If your protobufs (and their producer/consumers) are short-living, just remove the "required" field from your servers and clients at the same time. The "required is forever" problem persists only if you keep files with serialized protobuf data (or legacy binaries) and cannot reasonably update them at the same time.
Of course, once something hits production, you really cannot reasonably update them all at the same time. That's why the proto API has:
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message_lite#MessageLite.ParseFromString https://developers.google.com/protocol-buffers/docs/referenc...
bool ParseFromString(const string & data)
Parse a protocol buffer contained in a string.
bool ParsePartialFromString(const string & data)
Like ParseFromString(), but accepts messages that are missing required fields.
Or simply use "optional" instead as others suggested.
Also, even with these "bloated" definitions with legacy unused fields, it's probably still smaller than JSON.
- sergiosgc 12y agoCome on! That's sidestepping the issue. If you can change all clients and servers at the same time, there's no need for protocol versioning...