refactor(project): 重构项目并更新依赖

- 更新 README.md 中的项目结构说明
- 添加 pprof 性能分析工具的使用说明
- 更新 build.bat 文件,增加 proto 文件编译命令
- 升级 go-logr/logr 依赖至 v1.3.0
- 降级 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc 依赖至 v1.16.0
- 降级 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp 依赖至 v1.16.0
- 升级 go.opentelemetry.io/otel/trace 依赖至 v1.20.0
- 移除 logic/main.go 中的冗余代码
- 重构 logic/server.go 中的 Start 函数
- 更新 login/main.go 文件
This commit is contained in:
2025-07-06 17:05:10 +08:00
parent c16eed6fe0
commit 83ecb90baf
45 changed files with 7546 additions and 39 deletions

71
manifest/proto/rpc.proto Normal file
View File

@@ -0,0 +1,71 @@
syntax = "proto3";
// 指定 Go 包路径(推荐使用完整的模块路径)
option go_package = "/common/api";
package api;
// 注册请求 - logic 用户登录后注册
message RegisterUser {
int32 identity = 1; // 客户端身份,进入后保存id->端口 实现通知踢人以及进程退出
int32 user_id = 2; // 执行踢人操作的用户id
}
// 注册请求 - B客户端使用此消息向服务器注册
message KickRequest {
int32 user_id = 1; // 执行踢人操作的用户id
}
// 函数描述符
message FunctionDescriptor {
string function_name = 1; // 函数名称
string input_type = 2; // 输入参数类型
string output_type = 3; // 输出参数类型
string description = 4; // 函数描述
}
// 注册响应
message RegisterResponse {
bool success = 1; // 注册是否成功
string message = 2; // 消息描述
string registration_id = 3; // 注册ID
}
// 函数调用请求 - A客户端使用此消息请求调用B的函数
message FunctionCallRequest {
string target_client_id = 1; // 目标客户端IDB
string function_name = 2; // 要调用的函数名
bytes parameters = 3; // 序列化后的函数参数
string call_id = 4; // 调用ID用于关联响应
}
// 函数调用响应 - 从B客户端返回给A客户端
message FunctionCallResponse {
string call_id = 1; // 对应请求的调用ID
bool success = 2; // 调用是否成功
bytes result = 3; // 序列化后的返回结果
string error_message = 4; // 错误消息(如果失败)
}
// 通用消息
message GenericMessage {
oneof payload {
RegisterUser register_request = 1;
RegisterResponse register_response = 2;
FunctionCallRequest function_call_request = 3;
FunctionCallResponse function_call_response = 4;
string text_message = 5; // 普通文本消息
KickRequest kick_response = 6;
bool sucess = 7;
}
}
// 主服务接口
service BothWayStreamServer {
// 双向流连接 - 用于注册和函数调用
rpc Call (stream GenericMessage) returns (stream GenericMessage);
// 函数调用服务 - A客户端通过此方法请求调用B的函数
//rpc CallFunction (FunctionCallRequest) returns (FunctionCallResponse);
}