▲ | Analemma_ 7 days ago | ||||||||||||||||
The "no enums as map keys" thing enrages me constantly. Every protobuf project I've ever worked with either has stringly-typed maps all over the place because of this, or has to write its own function to parse Map<String, V> into Map<K, V> from the enums and then remember to call that right after deserialization, completely defeating the purpose of autogenerated types and deserializers. Why does Google put up with this? Surely it's the same inside their codebase. | |||||||||||||||||
▲ | Arainach 7 days ago | parent | next [-] | ||||||||||||||||
Maps are not a good fit for a wire protocol in my experience. Different languages often have different quirks around them, and they're non-trivial to represent in a type-safe way. If a Map is truly necessary I find it better to just send a repeated Message { Key K, Value V } and then convert that to a map in the receiving end. | |||||||||||||||||
▲ | dweis 7 days ago | parent | prev | next [-] | ||||||||||||||||
I believe that the reason for this limitation is that not all languages can represent open enums cleanly to gracefully handle unknown enums upon schema skew. | |||||||||||||||||
▲ | riku_iki 7 days ago | parent | prev [-] | ||||||||||||||||
And v1 and v2 protos didn't even have maps. Also, why you use string as a key and not int? | |||||||||||||||||
|