54 lines
1.3 KiB
Protocol Buffer
54 lines
1.3 KiB
Protocol Buffer
import "google/protobuf/descriptor.proto";
|
|
|
|
extend google.protobuf.FileOptions {
|
|
optional string my_file_option = 50000;
|
|
}
|
|
extend google.protobuf.MessageOptions {
|
|
optional int32 my_message_option = 50001;
|
|
}
|
|
extend google.protobuf.FieldOptions {
|
|
optional float my_field_option = 50002;
|
|
}
|
|
extend google.protobuf.EnumOptions {
|
|
optional bool my_enum_option = 50003;
|
|
}
|
|
extend google.protobuf.EnumValueOptions {
|
|
optional uint32 my_enum_value_option = 50004;
|
|
}
|
|
extend google.protobuf.ServiceOptions {
|
|
optional MyEnum my_service_option = 50005;
|
|
}
|
|
extend google.protobuf.MethodOptions {
|
|
optional MyMessage my_method_option = 50006;
|
|
}
|
|
|
|
option (my_file_option) = "Hello world!";
|
|
|
|
message MyMessage {
|
|
option (my_message_option) = 1234;
|
|
|
|
optional int32 foo = 1 [(my_field_option) = 4.5];
|
|
optional string bar = 2;
|
|
}
|
|
|
|
enum MyEnum {
|
|
option (my_enum_option) = true;
|
|
|
|
FOO = 1 [(my_enum_value_option) = 321];
|
|
BAR = 2;
|
|
}
|
|
|
|
message RequestType {}
|
|
message ResponseType {}
|
|
|
|
service MyService {
|
|
option (my_service_option) = FOO;
|
|
|
|
rpc MyMethod(RequestType) returns(ResponseType) {
|
|
// Note: my_method_option has type MyMessage. We can set each field
|
|
// within it using a separate "option" line.
|
|
option (my_method_option).foo = 567;
|
|
option (my_method_option).bar = "Some string";
|
|
}
|
|
}
|