-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarehouse.proto
More file actions
174 lines (147 loc) · 3.99 KB
/
warehouse.proto
File metadata and controls
174 lines (147 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
syntax = "proto3";
package warehouse;
// ==================== 仓库服务消息定义 ====================
// 下单请求
message OrderRequest {
string category = 1; // 一级分类
string subcategory = 2; // 二级分类
int32 item = 3; // 商品数量
}
// 下单响应
message OrderResponse {
string status = 1; // ok / out of stock
int32 left = 2; // 剩余库存
}
// 放入货物请求
message PutItemRequest {
string category = 1;
string subcategory = 2;
int32 item = 3; // 商品数量
}
// 放入货物响应
message PutItemResponse {
bool success = 1;
string message = 2;
}
// 更新货物请求
message UpdateItemRequest {
string category = 1;
string subcategory = 2;
int32 item = 3;
}
// 更新货物响应
message UpdateItemResponse {
bool success = 1;
string message = 2;
}
// 查询当前仓库请求
message ListItemsRequest {
string category = 1;
string subcategory = 2;
}
// 查询当前仓库响应
message ListItemsResponse {
repeated string items = 1; // 当前子类下所有物品
}
// ==================== 日志服务消息定义 ====================
// 日志记录请求
message LogRequest {
string service_name = 1; // 服务名称
string operation = 2; // 操作类型
string client_ip = 3; // 客户端IP
bool success = 4; // 操作是否成功
string request_data = 5; // 请求数据(JSON字符串)
string response_data = 6; // 响应数据(JSON字符串)
string error_message = 7; // 错误信息(可选)
}
// 日志记录响应
message LogResponse {
bool success = 1;
string message = 2;
}
// 查询日志请求
message QueryLogsRequest {
string service_name = 1; // 服务名称过滤(可选)
string operation = 2; // 操作类型过滤(可选)
int32 limit = 3; // 返回记录数量限制
}
// 查询日志响应
message QueryLogsResponse {
repeated LogEntry logs = 1;
int32 total_count = 2;
}
// 日志条目
message LogEntry {
string timestamp = 1;
string service_name = 2;
string operation = 3;
string client_ip = 4;
bool success = 5;
string request_data = 6;
string response_data = 7;
string error_message = 8;
}
// 统计信息请求
message StatsRequest {
// 空请求,返回所有统计信息
}
// 统计信息响应
message StatsResponse {
int32 total_operations = 1;
int32 successful_operations = 2;
int32 failed_operations = 3;
double success_rate = 4;
repeated ServiceStats service_stats = 5;
repeated OperationStats operation_stats = 6;
}
// 服务统计
message ServiceStats {
string service_name = 1;
int32 total = 2;
int32 success = 3;
int32 failed = 4;
double success_rate = 5;
}
// 操作统计
message OperationStats {
string operation = 1;
int32 total = 2;
int32 success = 3;
int32 failed = 4;
double success_rate = 5;
}
// ==================== 服务定义 ====================
// 仓库服务
service OrderService {
rpc PlaceOrder(OrderRequest) returns (OrderResponse);
rpc PutItem(PutItemRequest) returns (PutItemResponse);
rpc UpdateItem(UpdateItemRequest) returns (UpdateItemResponse);
rpc ListItems(ListItemsRequest) returns (ListItemsResponse);
rpc ConfigureLogging(ConfigureLoggingRequest) returns (ConfigureLoggingResponse);
}
// 清空日志请求
message ClearLogsRequest {
// 空消息,不需要参数
}
// 清空日志响应
message ClearLogsResponse {
bool success = 1;
string message = 2;
int32 cleared_count = 3;
}
// 配置日志请求
message ConfigureLoggingRequest {
bool enable_logging = 1; // 是否启用日志记录
}
// 配置日志响应
message ConfigureLoggingResponse {
bool success = 1;
string message = 2;
}
// 日志服务
service LoggerService {
rpc LogOperation(LogRequest) returns (LogResponse);
rpc QueryLogs(QueryLogsRequest) returns (QueryLogsResponse);
rpc GetStats(StatsRequest) returns (StatsResponse);
rpc ClearLogs(ClearLogsRequest) returns (ClearLogsResponse);
}