Hi,
I am new to protobuf.
I have question related to similar usecase.
Please clarify my doubts to decide better message specification
I have definition something like below
Option A
message Student
{
message Empty
{
}
//Name of the Student
optional string name = 1;
// Year of Passing
optional string YOP = 2;
message Certificate
{
// Certificate name
optional string name = 1;
// Absolute location of the file on the disk
// e.g. C:\university\2019\
optional string path = 2;
//strudent Identification code
optional string ID = 3;
// section e.g. "A", "B"
optional string section = 4;
// Certificate type
optional string type = 5;
}
optional Certificate cert = 3;
}
service StudentService
{
rpc getStudentName(Strudent.Empty) returns (Student);
rpc getCertificate(Student.Certificate) returns (Student.Certificate);
}
alternatively
Option B
message Student
{
//Name of the Student
optional string name = 1;
message FilePath
{
optional string path = 1;
}
message Certificate
{
optional string name = 1;
optional Filepath path = 2;
//strudent Identification code
optional string ID = 3;
// section e.g. "A", "B"
optional string section = 4;
// Certificate type
optional string type = 5;
}
optional Certificate cert = 2;
}
service StudentService
{
rpc getStudentName(Strudent.Empty) returns (Student);
rpc getCertificate(Student.Certificate.FilePath) returns (Student.Certificate);
}
In Option A, file path can not be specified to get the certificate. Full message needs to be passed.
In Option B, there is a extra type introduced to simplify
However it adds nested definition for path
as it has to be cert.path.path for getters and setters
Please clarify the following
Why scalar types can not be used as IN parameter or OUT parameters of Service RPCs?
How partial messages can be explicitly specified in service RPCs without using nesting?