|
|
|
|
|
by smallnamespace
3613 days ago
|
|
> I could trust that if parsing succeeded, then I had a guarantee of a populated data structure Using required fields have actually bit Google more than once and were increasingly being considered harmful. A canonical example is that you add a required field, and then update binaryA in production (which receives messages from binaryB), which immediately crashes or errors out because the new field is missing. So practically speaking, you can never add required fields to any message where you can't guarantee binary version syncing amongst all instances of the message-dependent services. At scale, this is essentially operationally impossible. And if you're not running an RPC-based service architecture, then why are you using protos anyway? |
|
Yeah. Don't do that without versioning your protocol. It's even less difficult to handle than maintaining API/ABI compatibility in a library.
> So practically speaking, you can never add required fields to any message where you can't guarantee binary version syncing amongst all instances of the message-dependent services.
Sure you can. If you version things at the protocol or per-request level, you can negotiate protocol conformance just fine.
Having a message type defined as "Message_V1" OR "Message_V2" is still simpler than having "any or none of the fields from any iteration of the message definition, where consistency is solely defined in terms of the field/message validation code you write in every protocol consumer".
> And if you're not running an RPC-based service architecture, then why are you using protos anyway?
It's a very serviceable compact serialization mechanism for at-rest data.