-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 新增上报 client metrics 数据 #2863
Conversation
Ambition9186
commented
Dec 25, 2023
- 客户端上报连接、心跳、变更、拉取事件到 feed-server
- cache-service 定时同步 client metrics 数据到 data-service
- data-service 定时更新客户端离线状态
c609957
to
f07b478
Compare
4f1ea16
to
36d1946
Compare
a098109
to
78ff81e
Compare
e953dec
to
31e27fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件在项目中已存在:
pkg/thirdparty/protobuf/google/protobuf/timestamp.proto
return values, nil | ||
} | ||
|
||
// RPop 移出并获取列表的第一个元素 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前面 LPush 是插入到头部,那这里就应该是从尾部移出并获取一个元素
logs.Infof("start handle client metric data") | ||
|
||
if !cm.state.IsMaster() { | ||
logs.V(2).Infof("this is slave, do not need to purge, skip. rid: %s", kt.Rid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个日志不对
return jsoni.Marshal(v) | ||
} | ||
|
||
// Decode the VersionChangePayload to bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Decode the VersionChangePayload from bytes.
return jsoni.Marshal(p) | ||
} | ||
|
||
// Decode the PullStatusPayload to bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Decode the PullStatusPayload from bytes.
@@ -196,6 +197,99 @@ func (s *Service) Messaging(ctx context.Context, msg *pbfs.MessagingMeta) (*pbfs | |||
return nil, status.Errorf(codes.PermissionDenied, "no permission to access bscp server") | |||
} | |||
|
|||
vc := new(sfs.VersionChangePayload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这几个变量都只是在对应的 case 中才被引用,不需要提前声明,在对应的 case 中声明就行了
// ClientMetric xxx | ||
type ClientMetric struct { | ||
mc *metric | ||
client gcache.Cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcache 是一个内存缓存库,这里客户端数据不需要在 feed_server 内存缓存,它不会被客户端读取,只用往 cache-service 写入就行了。
所以这里去掉这个 client
} | ||
|
||
// VersionChangePayload defines sdk version change to send payload to feed server. | ||
type VersionChangePayload struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
// ListClientByTuple Query the client list according to multiple fields in | ||
func (dao *clientDao) ListClientByTuple(kit *kit.Kit, data [][]interface{}) ([]*table.Client, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个注释给全一点,不然传入一个二维 interface{} 数组作为入参有点迷惑
} | ||
|
||
// Run the sync client online state task | ||
func (c *ClientOnlineState) Run() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数也需要支持主从,只有主服务负责定时同步客户端状态
dcd7ad3
to
9793f68
Compare
2. 新增客户端上报连接、心跳、变更、拉取事件到feed-server 3. 新增cache-service定时同步客户端metrics数据到data-service 4. 新增data-service定时更新客户端离线状态 5. 新增客户端类型字段
9793f68
to
fc7b67e
Compare