I have a use case where the incoming payload follows a top level schema and a nested schema. There can be 4 types of top level schema and infinite types of nested schema. I want to define my top level schemas in such a way that the internal schema can correspond to any message type in a directory. Is that possible with protobuf? If yes, how? And how would the decoding happen in such case
E.g.
message topLevelMessage {
string field1 = 1;
string field2 = 2;
string schemaType = 3;
schemaType payload = 4;
}
I have tried researching and the best response I have gotten so far is to use map
in protobuf which I'd rather not do
Edit: I'd also like to do something like below
message topLevelMessage {
string field1 = 1;
string field2 = 2;
string schemaType = 3;
repeated schemaType|messageType2|messageType3 payload = 4;
}
The motivation here is to make it easier to migrate our legacy service. Thereforce, there's less wiggle room