Skip to content

Commit 78a9afc

Browse files
committed
feat: 新增ClientEventType枚举并优化WatchClientEvents接口定义
1 parent 3bc7c4f commit 78a9afc

4 files changed

Lines changed: 226 additions & 134 deletions

File tree

api/v1/service_manage/client.proto

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,30 @@ message StatInfo {
5050

5151
}
5252

53-
// 服务端下发给客户端的事件
53+
// 客户端与服务端之间通过 WatchClientEvents 双向 stream 传递的事件消息
5454
message ClientEvent {
5555

56+
// 事件类型,用于区分上下行不同用途
57+
enum ClientEventType {
58+
// 未知类型,兼容默认值
59+
UNKNOWN = 0;
60+
// 上行:客户端发起事件监听(通常为 stream 建立后的第一条消息,用于自证身份)
61+
WATCH = 1;
62+
// 下行:服务端推送事件到客户端,index 表示该事件的序号,content 承载事件内容
63+
PUSH = 2;
64+
// 上行:客户端回复服务端,index 表示该事件的序号,content 承载回复内容
65+
ACK = 3;
66+
}
67+
68+
// 事件类型
69+
ClientEventType type = 1;
70+
5671
// 客户端ID
57-
string client_id = 1;
72+
string client_id = 2;
5873

5974
// 事件序号,服务端针对每个客户端的 stream 单调递增
60-
uint64 index = 2;
75+
uint64 index = 3;
6176

62-
// 事件内容,JSON 格式字符串
63-
string content = 3;
77+
// 事件或者回复内容,JSON 格式字符串
78+
string content = 4;
6479
}

api/v1/service_manage/grpcapi.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ service PolarisGRPC {
1717
// 上报客户端信息
1818
rpc ReportClient(Client) returns (Response) {}
1919
// 监听客户端事件
20-
rpc WatchClientEvents(stream Client) returns (stream ClientEvent) {}
20+
rpc WatchClientEvents(stream ClientEvent) returns (stream ClientEvent) {}
2121

2222
// 被调方注册服务实例
2323
rpc RegisterInstance(Instance) returns (Response) {}

source/go/api/v1/service_manage/client.pb.go

Lines changed: 125 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)