Hi
   I have a collection of message types which all share a common set of 
fields. Each message type has an additional number of attributes particular 
to that message type. Two choices I am considering on how to structure our 
schemas

Option A - import and compose
========================
common.proto
syntax = "proto3";

message Common 
{
                string fruit = 1;
                string vegetable = 2;
} 

messageA.proto
syntax = "proto3";
import "common.proto";

message messageA
{
                Common shared = 1;
                string cereal = 2;
}


Option B - Use Any in the common part
============================
common.proto
syntax = "proto3";

message Common 
{
                string fruit = 1;
                string vegetable = 2;
                Any  messageX = 3;
} 

messageA.proto
syntax = "proto3";
import "common.proto";

message messageA
{
        string cereal = 2;
}


Any advice or opinions on which choice is preferable? Would the Any route 
require an extra deserializing step that the composition route does not and 
be less efficient? It seems that after deserializing in the client, we 
still have to pull the any field, check the type and then additionally 
unpack it. Would the Any route require me to compile twice and generate two 
separate sets of files for each client - one for the Common.proto and one 
for the messageX.proto? Option A would require just a compile against 
messageX.proto.


Cheers
Mike

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to