I am creating message objects in proto3 and using auto-generated java classes. I want to have unique key assigned to each of the message object.
message Obj {
...
string unique_key = 1;
...
}
During construction of Obj
, it receives from a microservice, a proto object called metaData
, which is defined as follows:
message metData {
map<string, string> keyFields = 1;
}
Based on entries in metaData
object, unique_key
is created by iterating over the map and hashing each of the entries.(There are upto 10 entries in keyFields
)
The protobuf documentation says, the ordering of keys can't be defined. How should I guarantee that different metaData
objects with same entries in keyFields
generate same unique_key
?
You have two options in general: