56
votes

I would like to include a protocol definition file in another protocol file. For example:

// base.proto:
message P_EndPoint {
  required int32 id = 1;
  required string host = 2;
  required int32 port = 3;
}

Then in another file:

communication.proto:
// somehow include `base.proto'
// ...
message P_CommunicationProtocol {
  required CP_MessageType type = 1;
  optional int32 id = 2;
  optional P_EndPoint identity = 3;
  repeated P_EndPoint others = 4;
}
// ...

(Note: developers.google.com is not available in my locale)

1
developers.google.com/protocol-buffers/docs/proto#other specifically the part labeled "Importing Definitions" - Brian Roach
I can't access that URL. - sorush-r
this makes me realize how old grpc is!! - SZT

1 Answers