You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What language does this apply to?
proto2 and proto3
Describe the problem you are trying to solve.
I need to batch update some configuration value for a list of items, this value may have values in range -10…10 (including zero) but also it may be disabled.
Describe the solution you'd like map<string, optional int32> value = 1
Describe alternatives you've considered
map<string, MaybeInt32> value = 1 where MaybeInt32 is similar to google.protobuf.Int32Value (or contains extra bool set field for clarity) but a different message to work around protoc-gen-swagger: should well known types be nullable grpc-ecosystem/grpc-gateway#669 - it works, but it's ugly and less convenient to use than native "pointer to int32" type generated for optional in many languages
rewrite map as repeated message with key and (optional) value fields - the downside is it's became unclear from protocol that key must be unique
using value outside of allowed range to signal "disabled" - I believe downsides of such a "special" values are clear to anyone
Additional context
At a glance, adding optional support for map values feels natural, compatible with existing wire and proto formats and should make proto2/3 optional support more complete.
The text was updated successfully, but these errors were encountered:
Unfortunately this change is very unlikely. Under the hood, maps are implemented in language idiomatically which means that some languages wouldn't have proper data structures to store this data.
I think this is the best solution to your problem:
This will still keep your keys unique, not require any extra knowledge of special values, and will provide you the conveniences of other optional fields.
What language does this apply to?
proto2 and proto3
Describe the problem you are trying to solve.
I need to batch update some configuration value for a list of items, this value may have values in range -10…10 (including zero) but also it may be disabled.
Describe the solution you'd like
map<string, optional int32> value = 1
Describe alternatives you've considered
map<string, MaybeInt32> value = 1
where MaybeInt32 is similar to google.protobuf.Int32Value (or contains extrabool set
field for clarity) but a different message to work around protoc-gen-swagger: should well known types be nullable grpc-ecosystem/grpc-gateway#669 - it works, but it's ugly and less convenient to use than native "pointer to int32" type generated foroptional
in many languagesAdditional context
At a glance, adding
optional
support for map values feels natural, compatible with existing wire and proto formats and should make proto2/3optional
support more complete.The text was updated successfully, but these errors were encountered: