Skip to content

Commit

Permalink
1. 新增客户端metrics
Browse files Browse the repository at this point in the history
2. 新增客户端上报连接、心跳、变更、拉取事件到feed-server
3. 新增cache-service定时同步客户端metrics数据到data-service
4. 新增data-service定时更新客户端离线状态
5. 新增客户端类型字段
  • Loading branch information
Ambition9186 committed Jan 26, 2024
1 parent 2abd4d5 commit e953dec
Show file tree
Hide file tree
Showing 49 changed files with 8,350 additions and 2,482 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ build.yml
# bscp 软连接
bcs-services/bscp.io
.vscode
__debug_*

bcs-scenarios/bcs-kourse-rollout/bin/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ package client
import (
"context"

"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/cmd/cache-service/service/cache/keys"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/dal/bedis"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/dal/dao"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/dal/table"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/kit"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/logs"
pbclient "github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/protocol/core/client"
pbce "github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/protocol/core/client-event"
pbds "github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/protocol/data-service"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/runtime/jsoni"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/runtime/lock"
Expand All @@ -37,6 +40,8 @@ type Interface interface {
RefreshAppCache(kt *kit.Kit, bizID uint32, appID uint32) error
GetReleasedKv(kt *kit.Kit, bizID uint32, releaseID uint32) (string, error)
GetReleasedKvValue(kt *kit.Kit, bizID, appID, releaseID uint32, key string) (string, error)
SetClientMetric(kt *kit.Kit, bizID, appID uint32, payload []byte) error
BatchUpsertClientMetrics(kt *kit.Kit, clientData []*pbclient.Client, clientEventData []*pbce.ClientEvent) error
}

// New initialize a cache client.
Expand Down Expand Up @@ -103,3 +108,25 @@ func (c *client) RefreshAppCache(kt *kit.Kit, bizID uint32, appID uint32) error

return nil
}

// SetClientMetric set client metric data
func (c *client) SetClientMetric(kt *kit.Kit, bizID, appID uint32, payload []byte) error {
if err := c.bds.LPush(kt.Ctx, keys.Key.ClientMetricKey(bizID, appID), payload); err != nil {
return err
}
return nil
}

// BatchUpsertClientMetrics batch upsert client metrics data
func (c *client) BatchUpsertClientMetrics(kt *kit.Kit, clientData []*pbclient.Client,
clientEventData []*pbce.ClientEvent) error {
in := &pbds.BatchUpsertClientMetricsReq{
ClientItems: clientData,
ClientEventItems: clientEventData,
}
_, err := c.db.BatchUpsertClientMetrics(kt.Ctx, in)
if err != nil {
return err
}
return nil
}
Loading

0 comments on commit e953dec

Please sign in to comment.