Add terminal service implementation and integration tests

- Introduced terminal.h header file defining the terminal service API.
- Implemented integration tests for terminal service registration and health checks.
- Added unit tests for FFI layer, health checks, and terminal service functionality.
- Created a mock center for testing terminal registration and deregistration.
- Ensured proper error handling and response validation in tests.
This commit is contained in:
2026-09-20 10:55:38 +08:00
parent 3bef0e4ef2
commit 7f331565c7
90 changed files with 7807 additions and 14 deletions
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "proto"
version.workspace = true
edition.workspace = true
authors.workspace = true
[dependencies]
connectrpc.workspace = true
buffa.workspace = true
buffa-types.workspace = true
serde.workspace = true
[build-dependencies]
connectrpc-build.workspace = true
+14
View File
@@ -0,0 +1,14 @@
// 用于生成proto相关代码
fn main() {
connectrpc_build::Config::new()
.files(&[
"control/center.proto",
"control/terminal.proto",
"control/common/common.proto",
"third/grpc/health/v1/health.proto",
])
.includes(&["third/", "control/"])
.include_file("proto_gen.rs")
.compile()
.unwrap();
}
+106
View File
@@ -0,0 +1,106 @@
syntax = "proto3";
import "common/common.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "grpc/health/v1/health.proto";
package control;
/**
* 控制服务器
* 作为控制系统的核心组件, 对控制终端服务提供注册接口, 对其他组件提供查询和状态订阅接口
*/
service Center{
// 注册控制终端, 供控制终端调用, 通过该接口控制终端可以注册自己的信息
rpc RegisterTerminal(TerminalInfo) returns (TerminalRegisterResponse);
// 注销控制终端, 供控制终端调用, 通过该接口控制终端可以注销自己的信息, 入参为终端ID
rpc DeregisterTerminal(google.protobuf.StringValue) returns (control.InvokeResponse);
// 订阅控制终端列表, 供控制系统调用, 通过该接口控制系统可以订阅控制终端列表的变化, 返回值为控制终端列表的流式数据
rpc SubscribeTerminal(google.protobuf.Empty) returns (stream TerminalInfos);
}
/**
* @brief TerminalRegisterResponse 代表控制终端注册的响应结果, 包含注册是否成功和响应信息
* @details
* success 字段用于表示控制终端注册是否成功, true 表示成功, false 表示失败
* message 字段用于提供控制终端注册的响应信息, 供控制系统展示使用, 如果注册成功则该字段为id, 如果注册失败则该字段为错误信息
*/
message TerminalRegisterResponse {
bool success = 1;
string message = 2;
}
/**
* @brief TerminalType 代表控制终端支持的模拟类型, 包含类型名称, 类型描述, 图标URL和配置参数列表
* @details
* type_name 字段用于标识模拟类型的名称
* description 字段用于模拟类型的描述信息
* icon_url 字段用于模拟类型的图标URL, 供控制系统展示使用
* param_schema 字段用于描述模拟器的状态参数定义, 以键值对的形式存储, 键为参数名, 值为参数类型. 参数类型使用 ParameterType 枚举类型进行定义
* supported_commands 字段用于描述模拟器支持的命令列表
* @implementation_note 虽然目前设计中命令是动态的, 但是我们依然要求控制终端提供以下几个基础命令的支持, 以便控制系统进行基本的控制操作:
* - "init": 初始化终端的仿真功能, 该命令的参数定义与注册至中心的meta_info中的supported_commands中的parameter保持一致
* - "reset": 重置终端的仿真功能, 该命令的参数定义与注册至中心的meta_info中的supported_commands中的parameter保持一致
* - "start": 启动终端的仿真功能, 该命令的参数定义与注册至中心的meta_info中的supported_commands中的parameter保持一致
* - "stop": 停止终端的仿真功能, 该命令的参数定义与注册至中心的meta_info中的supported_commands中的parameter保持一致
* - "suspend": 暂停终端的仿真功能, 该命令的参数定义与注册至中心的meta_info中的supported_commands中的parameter保持一致
* - "resume": 恢复终端的仿真功能, 该命令的参数定义与注册至中心的meta_info中的supported_commands中的parameter保持一致
*/
message TerminalType{
string type_name = 1;
string description = 2;
string icon_url = 3;
map<string,ParameterType> param_schema = 4;
repeated TerminalCommandInfo supported_commands = 5;
}
/**
* @brief TerminalMetaInfo 代表控制终端的元信息, 包含支持的命令列表, 支持的终端类型列表和支持的事件列表
* @details
* supported_type 字段列出了控制终端支持的模拟类型
* extra_info 字段列出了控制终端提供的额外元信息
* @description extra_info 字段用于后续拓展, 基于后面可能的需求进行拓展
*/
message TerminalMetaInfo{
TerminalType supported_type = 1;
google.protobuf.Any extra_info = 2;
}
/**
* @brief TerminalInfo 代表控制终端的注册信息, 包含终端元信息, 终端主机地址和终端主机端口
* @details
* meta_info 字段包含了控制终端的元信息, 包括支持的终端类型以及此类型支持的命令列表
* terminal_host 和 terminal_port 同时用于终端服务监听和向中心注册地址.
* terminal_port 为0时, 终端绑定后应使用实际监听端口注册.
* 中心应按 terminal_mac 幂等注册或更新终端, 以支持安全重试.
*/
message TerminalInfo {
string terminal_host = 1;
uint32 terminal_port = 2;
string terminal_mac = 3;
TerminalMetaInfo meta_info = 4;
}
/**
* @brief TerminalRuntimeInfo 代表控制终端的运行时信息, 包含终端注册信息和终端状态
* @details
* info 字段包含了控制终端的注册信息, 包括终端元信息以及终端主机地址和端口
*/
message TerminalRuntimeInfo{
TerminalInfo info = 1;
grpc.health.v1.HealthCheckResponse.ServingStatus status = 2;
}
/**
* @brief TerminalInfos 代表多个控制终端的信息列表, 以键值对的形式存储, 键为终端ID, 值为终端信息
* @details
* infos 字段包含了多个控制终端的信息列表, 键为终端ID, 值为终端信息
*/
message TerminalInfos {
map<string, TerminalRuntimeInfo> infos = 1;
}
+101
View File
@@ -0,0 +1,101 @@
syntax = "proto3";
import "google/protobuf/any.proto";
package control;
/**
* @brief Parameter 代表一个可以封装任意类型值的消息, 包含字符串值, 整数值, 浮点数值和布尔值以及嵌套的子表和选择值
* @details
* Parameter 消息类型使用 oneof 字段来封装不同类型的值, 以支持多种参数类型的传递.
* 通过使用 Parameter 类型, 可以实现命令参数的灵活定义和扩展, 以适应不同命令的需求.
*/
message Parameter{
message Simple{
oneof value{
string string_value = 1;
int64 int_value = 2;
double double_value = 3;
bool bool_value = 4;
}
}
message SubTable{
map<string, Parameter> table = 1;
}
message Selected{
repeated string options = 1;
}
oneof value {
Simple simple_value = 1;
SubTable sub_table_value = 2;
Selected selected_value = 3;
}
}
/**
* @brief ParameterType 代表命令参数的类型
* @details
* ParameterType 消息类型使用枚举类型 Type 来定义参数的基本类型, 包括字符串, 整数, 浮点数和布尔值.
* 另外, ParameterType 还支持 Select 和 SubTable 类型, 以支持参数的选择和嵌套结构.
*/
message ParameterType{
enum Type {
STRING = 0;
INT = 1;
DOUBLE = 2;
BOOL = 3;
}
message Select{
repeated string options = 1;
}
message SubTable{
map<string, ParameterType> schema = 1;
}
oneof value{
Type type = 1;
Select select = 2;
SubTable sub_table = 3;
}
}
/*!
* @brief AsyncCommandResponse 代表控制终端异步命令的响应消息, 包含命令ID, 进度和消息
* @details
* cmd_id 字段用于唯一标识一个命令, 供控制系统进行命令的跟踪和管理
* progress 字段用于表示命令的执行进度, 范围为0.0到1.0
* message 字段用于提供命令执行的响应消息, 可以包含错误信息或者成功提示等内容
*/
message AsyncCommandResponse{
uint64 cmd_id = 1;
float progress = 2;
optional google.protobuf.Any data = 3;
}
/**
* @brief InvokeResponse 代表命令调用的响应结果, 包含调用是否成功和响应消息
* @details
* success 字段用于表示命令调用是否成功, true 表示成功, false 表示失败
* message 字段用于提供命令调用的响应消息, 可以包含错误信息或者成功提示等内容, 具体定义在extra路径下的proto文件中, 以便控制系统根据实际需求进行定制化设计.
*/
message InvokeResponse{
bool success = 1;
google.protobuf.Any message = 2;
}
/**
* @brief TerminalCommandInfo 代表控制终端支持的命令信息, 包含命令类型, 命令描述和命令参数类型列表
* @details
* id 字段用于标识命令的类型, 例如 "move", "stop"等等
* type 字段用于标识命令的可读类型, 例如 "移动", "停止"等等, 供控制系统展示使用
* description 字段用于描述命令的具体内容, 供控制系统展示使用
* icon_url 字段用于描述命令的图标URL, 供控制系统展示使用
* parameter 字段用于描述命令的参数类型列表, 以键值对的形式存储, 键为参数名, 值为参数类型.
* 参数类型使用 ParameterType 枚举类型进行定义
*/
message TerminalCommandInfo{
string id = 1;
string type = 2;
string description = 3;
string icon_url = 4;
map<string,ParameterType> parameter = 5;
}
+9
View File
@@ -0,0 +1,9 @@
syntax = "proto3";
package control;
message SceneRequest {
}
message SceneResponse{}
+9
View File
@@ -0,0 +1,9 @@
syntax = "proto3";
import "common/model.proto";
package control;
service Data{
rpc GetScene(SceneRequest) returns (SceneResponse);
}
+7
View File
@@ -0,0 +1,7 @@
syntax = "proto3";
package terminal.extra;
message SimExtra{
int64 sim_id = 1;
}
+120
View File
@@ -0,0 +1,120 @@
syntax = "proto3";
import "common/common.proto";
import "google/protobuf/empty.proto";
package control;
/**
* 控制终端服务
* 作为仿真端控制组件, 对外提供控制接口, 供控制系统调用
* @implementation_note 订阅接口保持空入参, 推送频率由终端实现统一控制.
*/
service Terminal{
// 执行命令, 供控制系统调用
rpc Execute(Command) returns (control.InvokeResponse);
// 发布事件, 供控制系统调用
// 此时的返回值中的message字段为事件运行时ID, 供控制系统进行事件的跟踪和管理
rpc PublishEvent(TerminalEvent) returns (control.InvokeResponse);
// 取消事件, 供控制系统调用, 入参为事件ID
rpc CancelEvent(TerminalCancelEvent) returns (control.InvokeResponse);
// 订阅终端状态, 供控制系统调用
rpc SubscribeStatus(google.protobuf.Empty) returns (stream TerminalStatus);
// 订阅终端元状态, 供控制系统调用
rpc SubscribeMetaStatus(google.protobuf.Empty) returns (stream TerminalMetaStatus);
}
/**
* @brief Command 代表控制系统发送给控制终端的命令, 包含命令类型和命令载荷
* @details
* id 字段用于标识命令的类型, 例如 "start", "stop"等等
* payload 字段用于携带命令的具体内容, 以键值对的形式存储, 键为参数名, 值为参数值.
* timestamp 字段用于标识命令的时间戳, 以毫秒为单位的Unix时间戳, 供控制终端进行命令的排序和处理
*/
message Command {
string id = 1;
int64 timestamp = 2;
map<string,Parameter> payload = 3;
}
/**
* @brief TerminalEventInfo 代表控制终端支持的事件信息, 包含事件ID, 事件类型, 事件名称, 事件描述, 事件载荷的参数定义
* @details
* event_id 字段用于唯一标识一个事件
* event_type 字段用于标识事件的类型, 例如 "critical", "emergency"等等
* event_name 字段用于事件的名称, 供控制系统展示使用
* description 字段用于描述事件的具体内容, 供控制系统展示使用
* payload_schema 字段用于描述事件载荷的参数定义, 以键值对的形式存储, 键为参数名, 值为参数类型. 参数类型使用 ParameterType 枚举类型进行定义
* @implementation_note 目前设计中, 事件的定义是动态的, 由终端在运行时根据实际情况进行定义和更新. 但是我们要求终端实现中不进行特情("emergency")类型的事件的实现与注册
* 特情事件是控制系统预定义的一类事件, 具有特殊的含义和处理逻辑. 在提供的动态库中通过外挂脚本的形式进行特情事件的定义和注册, 以便控制系统根据实际需求进行特情事件的定制化设计.
* 终端实现中不进行特情事件的定义和注册, 可以避免终端实现与控制系统预定义的特情事件发生冲突, 同时也可以简化终端实现的设计和开发.
*/
message TerminalEventInfo{
string event_id = 1;
string event_type = 2;
string event_category = 3;
string event_name = 4;
string description = 5;
map<string,ParameterType> payload_schema = 6;
}
/**
* @brief TerminalEvent 代表控制终端的事件信息, 包含事件ID, 触发延迟, 重复周期和事件载荷
* @details
* event_id 字段用于唯一标识一个事件
* trigger_delay_ms 字段用于表示事件触发的延迟时间, 单位为毫秒, 如果该字段值为0, 则表示事件立即触发
* repeat_period_ms 字段用于表示事件的重复周期, 单位为毫秒, 如果该字段值为0, 则表示该事件不重复
* payload 字段用于携带事件的具体内容, 以键值对的形式存储, 键为参数名, 值为参数值.
*/
message TerminalEvent{
string event_id = 1;
uint64 trigger_delay_ms = 2;
uint64 repeat_period_ms = 3;
map<string,Parameter> payload = 4;
}
message TerminalCancelEvent{
string event_id = 1;
uint64 instance_id = 2;
}
message TerminalEventHandle{
string event_id = 1;
uint64 instance_id = 2;
}
/**
* @brief TerminalStatus 控制终端高频状态的消息格式, 包含当前参数列表, 状态序列号和状态时间戳
* @details
* sequence 字段表示状态的序列号, 每次状态更新时递增, 供控制系统跟踪状态的变化
* timestamp 字段表示状态的时间戳, 以毫秒为单位的Unix时间戳, 供控制系统跟踪状态的变化时间
* current_param 字段表示当前终端的参数, 与注册至中心的meta_info中的param_schema保持一致
* @implementation_note 目前设计中, 状态信息推送频率由终端实现进行控制, 最大推送频率为 100hz
* @implementation_note 状态字段保持动态参数表, 以支持不同仿真类型的状态模型.
*/
message TerminalStatus{
uint64 sequence = 1;
int64 timestamp = 2;
map<string,Parameter> current_param = 3;
}
/**
* @brief TerminalMetaStatus 代表控制终端的元状态信息, 包含终端ID, 可发布事件列表和已触发事件列表
* @details
* terminal_id 字段用于唯一标识一个控制终端
* publishable_events 字段表示终端当前可发布的事件列表, 供控制系统展示使用
* triggered_events 字段表示终端当前已触发的事件列表, 供控制系统展示使用, key为instance_id, value为事件信息
* @implementation_note 目前设计中, 终端的元状态信息推送为低频推送, 即push_on_change策略, 以降低系统的负载.
* - 终端可发布的事件列表发生变化时, 例如新增了一个 "critical" 类型的事件
* - 终端已触发的事件列表发生变化时, 例如触发了一个 "emergency" 类型的事件
*/
message TerminalMetaStatus{
string terminal_id = 1;
repeated TerminalEventInfo publishable_events = 2;
map<uint64, string> triggered_events = 3;
}
+3
View File
@@ -0,0 +1,3 @@
pub mod proto {
connectrpc::include_generated!("proto_gen.rs");
}
+3
View File
@@ -0,0 +1,3 @@
syntax = "proto3";
package google.api;
// Placeholder for option definitions; kept minimal for tooling.
+16
View File
@@ -0,0 +1,16 @@
syntax = "proto3";
package google.api;
enum ClientLibraryOrganization {
CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0;
GOOGLE = 1;
CLOUD = 2;
}
enum ClientLibraryDestination {
CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0;
GITHUB = 10;
PACKAGE_MANAGER = 20;
}
message CommonLanguageSettings {
string reference_docs_uri = 1;
repeated string destinations = 2;
}
@@ -0,0 +1,10 @@
syntax = "proto3";
package google.api;
enum FieldBehavior {
FIELD_BEHAVIOR_UNSPECIFIED = 0;
OPTIONAL = 1;
REQUIRED = 2;
OUTPUT_ONLY = 3;
INPUT_ONLY = 4;
IMMUTABLE = 5;
}
+20
View File
@@ -0,0 +1,20 @@
syntax = "proto3";
package google.api;
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
+12
View File
@@ -0,0 +1,12 @@
syntax = "proto3";
package google.api;
enum LaunchStage {
LAUNCH_STAGE_UNSPECIFIED = 0;
UNIMPLEMENTED = 6;
PRELAUNCH = 7;
EARLY_ACCESS = 1;
ALPHA = 2;
BETA = 3;
GA = 4;
DEPRECATED = 5;
}
+14
View File
@@ -0,0 +1,14 @@
syntax = "proto3";
package google.api;
message ResourceDescriptor {
string type = 1;
repeated string pattern = 2;
string name_field = 3;
string history = 4;
repeated string plural = 5;
string singular = 6;
}
message ResourceReference {
string type = 1;
string child_type = 2;
}
+9
View File
@@ -0,0 +1,9 @@
syntax = "proto3";
package google.api;
message VisibilityRule {
string selector = 1;
string restriction = 2;
}
message Visibility {
repeated VisibilityRule rules = 1;
}
@@ -0,0 +1,10 @@
syntax = "proto3";
package google.cloud.audit;
import "google/rpc/status.proto";
message AuditLog {
string service_name = 7;
string method_name = 8;
string resource_name = 11;
string principal_subject = 13;
google.rpc.Status status = 2;
}
@@ -0,0 +1,13 @@
syntax = "proto3";
package google.logging.type;
message HttpRequest {
string request_method = 1;
string request_url = 2;
int64 status = 3;
int64 response_size = 4;
string user_agent = 5;
string remote_ip = 6;
string referer = 7;
bool cache_hit = 8;
bool cache_validated_with_origin_server = 9;
}
@@ -0,0 +1,13 @@
syntax = "proto3";
package google.logging.type;
enum LogSeverity {
DEFAULT = 0;
DEBUG = 100;
INFO = 200;
NOTICE = 300;
WARNING = 400;
ERROR = 500;
CRITICAL = 600;
ALERT = 700;
EMERGENCY = 800;
}
@@ -0,0 +1,11 @@
syntax = "proto3";
package google.longrunning;
import "google/protobuf/any.proto";
import "google/rpc/status.proto";
message Operation {
string name = 1;
google.protobuf.Any metadata = 2;
bool done = 3;
google.rpc.Status error = 4;
google.protobuf.Any response = 5;
}
+6
View File
@@ -0,0 +1,6 @@
syntax = "proto3";
package google.protobuf;
message Any {
string type_url = 1;
bytes value = 2;
}
@@ -0,0 +1,396 @@
syntax = "proto2";
package google.protobuf;
message FileDescriptorSet {
repeated FileDescriptorProto file = 1;
}
message FileDescriptorProto {
optional string name = 1;
optional string package = 2;
repeated string dependency = 3;
repeated int32 public_dependency = 10;
repeated int32 weak_dependency = 11;
repeated DescriptorProto message_type = 4;
repeated EnumDescriptorProto enum_type = 5;
repeated ServiceDescriptorProto service = 6;
repeated FieldDescriptorProto extension = 7;
optional FileOptions options = 8;
optional SourceCodeInfo source_code_info = 9;
optional string syntax = 12;
optional Edition edition = 14;
}
message DescriptorProto {
optional string name = 1;
repeated FieldDescriptorProto field = 2;
repeated FieldDescriptorProto extension = 6;
repeated DescriptorProto nested_type = 3;
repeated EnumDescriptorProto enum_type = 4;
repeated ExtensionRange extension_range = 5;
repeated OneofDescriptorProto oneof_decl = 8;
optional MessageOptions options = 7;
repeated ReservedRange reserved_range = 9;
repeated string reserved_name = 10;
message ExtensionRange {
optional int32 start = 1;
optional int32 end = 2;
optional ExtensionRangeOptions options = 3;
}
message ReservedRange {
optional int32 start = 1;
optional int32 end = 2;
}
}
message ExtensionRangeOptions {
repeated UninterpretedOption uninterpreted_option = 999;
repeated Declaration declaration = 2;
optional FeatureSet features = 50;
enum VerificationState {
DECLARATION = 0;
UNVERIFIED = 1;
}
optional VerificationState verification = 3 [default = UNVERIFIED];
message Declaration {
optional int32 number = 1;
optional string full_name = 2;
optional string type = 3;
optional bool reserved = 5;
optional bool repeated = 6;
}
}
message FieldDescriptorProto {
enum Type {
TYPE_DOUBLE = 1;
TYPE_FLOAT = 2;
TYPE_INT64 = 3;
TYPE_UINT64 = 4;
TYPE_INT32 = 5;
TYPE_FIXED64 = 6;
TYPE_FIXED32 = 7;
TYPE_BOOL = 8;
TYPE_STRING = 9;
TYPE_GROUP = 10;
TYPE_MESSAGE = 11;
TYPE_BYTES = 12;
TYPE_UINT32 = 13;
TYPE_ENUM = 14;
TYPE_SFIXED32 = 15;
TYPE_SFIXED64 = 16;
TYPE_SINT32 = 17;
TYPE_SINT64 = 18;
}
enum Label {
LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2;
LABEL_REPEATED = 3;
}
optional string name = 1;
optional int32 number = 3;
optional Label label = 4;
optional Type type = 5;
optional string type_name = 6;
optional string extendee = 2;
optional string default_value = 7;
optional int32 oneof_index = 9;
optional string json_name = 10;
optional FieldOptions options = 8;
optional bool proto3_optional = 17;
}
message OneofDescriptorProto {
optional string name = 1;
optional OneofOptions options = 2;
}
message EnumDescriptorProto {
optional string name = 1;
repeated EnumValueDescriptorProto value = 2;
optional EnumOptions options = 3;
repeated EnumReservedRange reserved_range = 4;
repeated string reserved_name = 5;
message EnumReservedRange {
optional int32 start = 1;
optional int32 end = 2;
}
}
message EnumValueDescriptorProto {
optional string name = 1;
optional int32 number = 2;
optional EnumValueOptions options = 3;
}
message ServiceDescriptorProto {
optional string name = 1;
repeated MethodDescriptorProto method = 2;
optional ServiceOptions options = 3;
}
message MethodDescriptorProto {
optional string name = 1;
optional string input_type = 2;
optional string output_type = 3;
optional MethodOptions options = 4;
optional bool client_streaming = 5 [default = false];
optional bool server_streaming = 6 [default = false];
}
enum Edition {
EDITION_UNKNOWN = 0;
EDITION_PROTO2 = 998;
EDITION_PROTO3 = 999;
EDITION_2023 = 1000;
EDITION_2024 = 1001;
EDITION_1_TEST_ONLY = 1;
EDITION_2_TEST_ONLY = 2;
EDITION_99997_TEST_ONLY = 99997;
EDITION_99998_TEST_ONLY = 99998;
EDITION_99999_TEST_ONLY = 99999;
EDITION_MAX = 2147483647;
}
message FileOptions {
optional string java_package = 1;
optional string java_outer_classname = 8;
optional bool java_multiple_files = 10 [default = false];
optional bool java_generate_equals_and_hash = 20 [deprecated = true];
optional bool java_string_check_utf8 = 27 [default = false];
enum OptimizeMode {
SPEED = 1;
CODE_SIZE = 2;
LITE_RUNTIME = 3;
}
optional OptimizeMode optimize_for = 9 [default = SPEED];
optional string go_package = 11;
optional bool cc_generic_services = 16 [default = false];
optional bool java_generic_services = 17 [default = false];
optional bool py_generic_services = 18 [default = false];
optional bool deprecated = 23 [default = false];
optional bool cc_enable_arenas = 31 [default = true];
optional string objc_class_prefix = 36;
optional string csharp_namespace = 37;
optional string swift_prefix = 39;
optional string php_class_prefix = 40;
optional string php_namespace = 41;
optional string php_metadata_namespace = 44;
optional string ruby_package = 45;
optional FeatureSet features = 50;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message MessageOptions {
optional bool message_set_wire_format = 1 [default = false];
optional bool no_standard_descriptor_accessor = 2 [default = false];
optional bool deprecated = 3 [default = false];
optional bool map_entry = 7;
optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
optional FeatureSet features = 12;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message FieldOptions {
enum CType {
STRING = 0;
CORD = 1;
STRING_PIECE = 2;
}
optional CType ctype = 1 [default = STRING];
optional bool packed = 2;
enum JSType {
JS_NORMAL = 0;
JS_STRING = 1;
JS_NUMBER = 2;
}
optional JSType jstype = 6 [default = JS_NORMAL];
optional bool lazy = 5 [default = false];
optional bool unverified_lazy = 15 [default = false];
optional bool deprecated = 3 [default = false];
optional bool weak = 10 [default = false];
optional bool debug_redact = 16 [default = false];
enum OptionRetention {
RETENTION_UNKNOWN = 0;
RETENTION_RUNTIME = 1;
RETENTION_SOURCE = 2;
}
optional OptionRetention retention = 17;
enum OptionTargetType {
TARGET_TYPE_UNKNOWN = 0;
TARGET_TYPE_FILE = 1;
TARGET_TYPE_EXTENSION_RANGE = 2;
TARGET_TYPE_MESSAGE = 3;
TARGET_TYPE_FIELD = 4;
TARGET_TYPE_ONEOF = 5;
TARGET_TYPE_ENUM = 6;
TARGET_TYPE_ENUM_ENTRY = 7;
TARGET_TYPE_SERVICE = 8;
TARGET_TYPE_METHOD = 9;
}
repeated OptionTargetType targets = 19;
repeated EditionDefault edition_defaults = 20;
optional FeatureSet features = 21;
optional FeatureSupport feature_support = 22;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
message EditionDefault {
optional Edition edition = 3;
optional string value = 2;
}
message FeatureSupport {
optional Edition edition_introduced = 1;
optional Edition edition_deprecated = 2;
optional string deprecation_warning = 3;
optional Edition edition_removed = 4;
}
}
message OneofOptions {
optional FeatureSet features = 1;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message EnumOptions {
optional bool allow_alias = 2;
optional bool deprecated = 3 [default = false];
optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
optional FeatureSet features = 7;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message EnumValueOptions {
optional bool deprecated = 1 [default = false];
optional FeatureSet features = 2;
optional bool debug_redact = 3 [default = false];
optional FieldOptions.FeatureSupport feature_support = 4;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message ServiceOptions {
optional FeatureSet features = 34;
optional bool deprecated = 33 [default = false];
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message MethodOptions {
optional bool deprecated = 33 [default = false];
enum IdempotencyLevel {
IDEMPOTENCY_UNKNOWN = 0;
NO_SIDE_EFFECTS = 1;
IDEMPOTENT = 2;
}
optional IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
optional FeatureSet features = 35;
repeated UninterpretedOption uninterpreted_option = 999;
extensions 1000 to max;
}
message UninterpretedOption {
message NamePart {
required string name_part = 1;
required bool is_extension = 2;
}
repeated NamePart name = 2;
optional string identifier_value = 3;
optional uint64 positive_int_value = 4;
optional int64 negative_int_value = 5;
optional double double_value = 6;
optional bytes string_value = 7;
optional string aggregate_value = 8;
}
message FeatureSet {
enum FieldPresence {
FIELD_PRESENCE_UNKNOWN = 0;
EXPLICIT = 1;
IMPLICIT = 2;
LEGACY_REQUIRED = 3;
}
optional FieldPresence field_presence = 1;
enum EnumType {
ENUM_TYPE_UNKNOWN = 0;
OPEN = 1;
CLOSED = 2;
}
optional EnumType enum_type = 2;
enum RepeatedFieldEncoding {
REPEATED_FIELD_ENCODING_UNKNOWN = 0;
PACKED = 1;
EXPANDED = 2;
}
optional RepeatedFieldEncoding repeated_field_encoding = 3;
enum Utf8Validation {
UTF8_VALIDATION_UNKNOWN = 0;
VERIFY = 2;
NONE = 3;
}
optional Utf8Validation utf8_validation = 4;
enum MessageEncoding {
MESSAGE_ENCODING_UNKNOWN = 0;
LENGTH_PREFIXED = 1;
DELIMITED = 2;
}
optional MessageEncoding message_encoding = 5;
enum JsonFormat {
JSON_FORMAT_UNKNOWN = 0;
ALLOW = 1;
LEGACY_BEST_EFFORT = 2;
}
optional JsonFormat json_format = 6;
extensions 1000 to 9994;
extensions 9995 to 9999;
extensions 10000;
}
message FeatureSetDefaults {
message FeatureSetEditionDefault {
optional Edition edition = 3;
optional FeatureSet overridable_features = 4;
optional FeatureSet fixed_features = 5;
}
repeated FeatureSetEditionDefault defaults = 1;
optional Edition minimum_edition = 4;
optional Edition maximum_edition = 5;
}
message SourceCodeInfo {
repeated Location location = 1;
message Location {
repeated int32 path = 1 [packed = true];
repeated int32 span = 2 [packed = true];
optional string leading_comments = 3;
optional string trailing_comments = 4;
repeated string leading_detached_comments = 6;
}
}
message GeneratedCodeInfo {
repeated Annotation annotation = 1;
message Annotation {
repeated int32 path = 1 [packed = true];
optional string source_file = 2;
optional int32 begin = 3;
optional int32 end = 4;
enum Semantic {
NONE = 0;
SET = 1;
ALIAS = 2;
}
optional Semantic semantic = 5;
}
}
@@ -0,0 +1,6 @@
syntax = "proto3";
package google.protobuf;
message Duration {
int64 seconds = 1;
int32 nanos = 2;
}
+3
View File
@@ -0,0 +1,3 @@
syntax = "proto3";
package google.protobuf;
message Empty {}
@@ -0,0 +1,5 @@
syntax = "proto3";
package google.protobuf;
message FieldMask {
repeated string paths = 1;
}
+21
View File
@@ -0,0 +1,21 @@
syntax = "proto3";
package google.protobuf;
enum NullValue {
NULL_VALUE = 0;
}
message Struct {
map<string, Value> fields = 1;
}
message Value {
oneof kind {
NullValue null_value = 1;
double number_value = 2;
string string_value = 3;
bool bool_value = 4;
Struct struct_value = 5;
ListValue list_value = 6;
}
}
message ListValue {
repeated Value values = 1;
}
@@ -0,0 +1,6 @@
syntax = "proto3";
package google.protobuf;
message Timestamp {
int64 seconds = 1;
int32 nanos = 2;
}
@@ -0,0 +1,11 @@
syntax = "proto3";
package google.protobuf;
message DoubleValue { double value = 1; }
message FloatValue { float value = 1; }
message Int64Value { int64 value = 1; }
message UInt64Value { uint64 value = 1; }
message Int32Value { int32 value = 1; }
message UInt32Value { uint32 value = 1; }
message BoolValue { bool value = 1; }
message StringValue { string value = 1; }
message BytesValue { bytes value = 1; }
+21
View File
@@ -0,0 +1,21 @@
syntax = "proto3";
package google.rpc;
enum Code {
OK = 0;
CANCELLED = 1;
UNKNOWN = 2;
INVALID_ARGUMENT = 3;
DEADLINE_EXCEEDED = 4;
NOT_FOUND = 5;
ALREADY_EXISTS = 6;
PERMISSION_DENIED = 7;
RESOURCE_EXHAUSTED = 8;
FAILED_PRECONDITION = 9;
ABORTED = 10;
OUT_OF_RANGE = 11;
UNIMPLEMENTED = 12;
INTERNAL = 13;
UNAVAILABLE = 14;
DATA_LOSS = 15;
UNAUTHENTICATED = 16;
}
@@ -0,0 +1,58 @@
syntax = "proto3";
package google.rpc;
import "google/protobuf/duration.proto";
message RetryInfo {
google.protobuf.Duration retry_delay = 1;
}
message DebugInfo {
repeated string stack_entries = 1;
string detail = 2;
}
message QuotaFailure {
message Violation {
string subject = 1;
string description = 2;
}
repeated Violation violations = 1;
}
message ErrorInfo {
string reason = 1;
string domain = 2;
map<string, string> metadata = 3;
}
message PreconditionFailure {
message Violation {
string type = 1;
string subject = 2;
string description = 3;
}
repeated Violation violations = 1;
}
message BadRequest {
message FieldViolation {
string field = 1;
string description = 2;
}
repeated FieldViolation field_violations = 1;
}
message RequestInfo {
string request_id = 1;
string serving_data = 2;
}
message ResourceInfo {
string resource_type = 1;
string resource_name = 2;
string owner = 3;
string description = 4;
}
message Help {
message Link {
string description = 1;
string url = 2;
}
repeated Link links = 1;
}
message LocalizedMessage {
string locale = 1;
string message = 2;
}
+8
View File
@@ -0,0 +1,8 @@
syntax = "proto3";
package google.rpc;
import "google/protobuf/any.proto";
message Status {
int32 code = 1;
string message = 2;
repeated google.protobuf.Any details = 3;
}
+8
View File
@@ -0,0 +1,8 @@
syntax = "proto3";
package google.type;
message Color {
float red = 1;
float green = 2;
float blue = 3;
float alpha = 4;
}
+7
View File
@@ -0,0 +1,7 @@
syntax = "proto3";
package google.type;
message Date {
int32 year = 1;
int32 month = 2;
int32 day = 3;
}
+19
View File
@@ -0,0 +1,19 @@
syntax = "proto3";
package google.type;
message TimeZone {
string id = 1;
int32 version = 2;
}
message DateTime {
int32 year = 1;
int32 month = 2;
int32 day = 3;
int32 hours = 4;
int32 minutes = 5;
int32 seconds = 6;
int32 nanos = 7;
oneof time_offset {
int32 utc_offset = 8;
TimeZone time_zone = 9;
}
}
+8
View File
@@ -0,0 +1,8 @@
syntax = "proto3";
package google.type;
message Expr {
string expression = 1;
string title = 2;
string description = 3;
string location = 4;
}
+6
View File
@@ -0,0 +1,6 @@
syntax = "proto3";
package google.type;
message LatLng {
double latitude = 1;
double longitude = 2;
}
@@ -0,0 +1,6 @@
syntax = "proto3";
package google.type;
message LocalizedText {
string text = 1;
string language_code = 2;
}
+7
View File
@@ -0,0 +1,7 @@
syntax = "proto3";
package google.type;
message Money {
string currency_code = 1;
int64 units = 2;
int32 nanos = 3;
}
@@ -0,0 +1,6 @@
syntax = "proto3";
package google.type;
message PhoneNumber {
string e164_number = 1;
string extension = 2;
}
@@ -0,0 +1,13 @@
syntax = "proto3";
package google.type;
message PostalAddress {
string region_code = 1;
string language_code = 2;
string postal_code = 3;
string administrative_area = 4;
string locality = 5;
string sublocality = 6;
repeated string address_lines = 7;
repeated string recipients = 8;
string organization = 9;
}
+8
View File
@@ -0,0 +1,8 @@
syntax = "proto3";
package google.type;
message TimeOfDay {
int32 hours = 1;
int32 minutes = 2;
int32 seconds = 3;
int32 nanos = 4;
}
+63
View File
@@ -0,0 +1,63 @@
// Copyright 2015 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// The canonical version of this proto can be found at
// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto
syntax = "proto3";
package grpc.health.v1;
option csharp_namespace = "Grpc.Health.V1";
option go_package = "google.golang.org/grpc/health/grpc_health_v1";
option java_multiple_files = true;
option java_outer_classname = "HealthProto";
option java_package = "io.grpc.health.v1";
message HealthCheckRequest {
string service = 1;
}
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
SERVICE_UNKNOWN = 3; // Used only by the Watch method.
}
ServingStatus status = 1;
}
service Health {
// If the requested service is unknown, the call will fail with status
// NOT_FOUND.
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
// Performs a watch for the serving status of the requested service.
// The server will immediately send back a message indicating the current
// serving status. It will then subsequently send a new message whenever
// the service's serving status changes.
//
// If the requested service is unknown when the call is received, the
// server will send a message setting the serving status to
// SERVICE_UNKNOWN but will *not* terminate the call. If at some
// future point, the serving status of the service becomes known, the
// server will send a new message with the service's serving status.
//
// If the call terminates with status UNIMPLEMENTED, then clients
// should assume this method is not supported and should not retry the
// call. If the call terminates with any other status (including OK),
// clients should retry the call with appropriate exponential backoff.
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
}