Compare commits

..

No commits in common. 'eee10936ea9ea0b57ec5bc9553ad2a5fef340ca8' and '74149d336cb217d454823c23710ee156b01ee8d5' have entirely different histories.

  1. 6
      Jenkinsfile
  2. 36
      go.mod
  3. 37
      task/task.go

6
Jenkinsfile vendored

@ -106,7 +106,7 @@ pipeline {
// 首次部署需要使用,后期可以直接注释掉此步骤
stage('传入yaml') {
steps {
// yaml()
yaml()
echo '传入yaml 完成'
}
}
@ -114,13 +114,13 @@ pipeline {
stage('apply') {
steps {
// apply()
apply()
echo '执行apply 完成'
}
}
stage('更新image') {
steps {
image()
// image()
echo '更新image 完成'
}

36
go.mod

@ -3,30 +3,30 @@ module git.gz.internal.jumaiyx.cn/job/hotspot-clear
go 1.20
require (
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20240620093131-a7998314087b
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20240515061156-c1741246ef08
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20240415093446-0004fca23b7b
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20231123090823-91017d7a1a1e
git.gz.internal.jumaiyx.cn/pkg/config/v2 v2.0.0-20240312130125-0f8bbcc94011
git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2 v2.0.3-0.20240514095615-2923c1384547
git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2 v2.0.3-0.20240229083126-a1abe7ddc19f
git.gz.internal.jumaiyx.cn/pkg/webhook v0.0.0-20240314063906-8db8467590c4
github.com/redis/go-redis/v9 v9.5.1
)
require (
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20240514095004-cb5816f3b6ee // indirect
git.gz.internal.jumaiyx.cn/proto/game-server v0.0.0-20240423100311-c410de6080d6 // indirect
git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20240229083231-fa19d823f204 // indirect
git.gz.internal.jumaiyx.cn/proto/game-server v0.0.0-20231031074443-b9b51900f07a // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/go-kratos/aegis v0.2.0 // indirect
github.com/go-kratos/kratos/v2 v2.7.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/form/v4 v4.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.4.0 // indirect
@ -41,27 +41,27 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.9 // indirect
k8s.io/apimachinery v0.28.9 // indirect
k8s.io/client-go v0.28.9 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
k8s.io/api v0.28.3 // indirect
k8s.io/apimachinery v0.28.3 // indirect
k8s.io/client-go v0.28.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect

37
task/task.go

@ -2,7 +2,7 @@ package task
import (
"context"
onlinev1 "git.gz.internal.jumaiyx.cn/jm/jmproto/online/v1"
livev1 "git.gz.internal.jumaiyx.cn/jm/jmproto/live/v1"
v2 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v2"
"git.gz.internal.jumaiyx.cn/pkg/client"
configv2 "git.gz.internal.jumaiyx.cn/pkg/config/v2"
@ -50,11 +50,9 @@ func NewTask() {
}
func task(start, end int64) error {
ctx := context.Background()
redisClient := NewRedis()
//defer func() { redisClient.Close() }()
result, err := redisClient.ZRangeWithScores(ctx, hotKey, start, end).Result()
result, err := redisClient.ZRangeWithScores(context.Background(), hotKey, start, end).Result()
if err != nil {
return err
}
@ -78,35 +76,24 @@ func task(start, end int64) error {
}
}
if len(ids) != 0 {
err = redisClient.ZAdd(ctx, hotKey, members...).Err()
err = redisClient.ZAdd(context.Background(), hotKey, members...).Err()
if err != nil {
return err
}
//liveClient, liveClientClose, err := client.GetLiveClient(ctx)
//if err != nil {
// return err
//}
//defer func() { _ = liveClientClose() }()
//
//onlineTotalResp, err := liveClient.GetLiveOnlineTotal(ctx, &livev1.GetLiveOnlineTotalReq{
// RoomIdList: ids,
//})
//if err != nil {
// return err
//}
onlineClient, onlineClientClose, err := client.GetOnlineClient(ctx)
liveClient, liveClientClose, err := client.GetLiveClient(context.Background())
if err != nil {
return err
}
defer func() { _ = onlineClientClose() }()
onlineTotalResp, err := onlineClient.GetLiveOnlineTotal(ctx, &onlinev1.GetLiveOnlineTotalRequest{
defer func() { _ = liveClientClose() }()
onlineTotalResp, err := liveClient.GetLiveOnlineTotal(context.Background(), &livev1.GetLiveOnlineTotalReq{
RoomIdList: ids,
})
if err != nil {
return err
}
roomClient, roomClientClose, err := client.GetRoomClientV2(ctx)
roomClient, roomClientClose, err := client.GetRoomClientV2(context.Background())
if err != nil {
return err
}
@ -120,7 +107,7 @@ func task(start, end int64) error {
HotValue: int32(online) * 10,
})
}
_, err = roomClient.IncrRoomHotspot(ctx, &v2.IncrRoomHotspotReq{
_, err = roomClient.IncrRoomHotspot(context.Background(), &v2.IncrRoomHotspotReq{
Items: items,
})
if err != nil {
@ -135,10 +122,7 @@ func task(start, end int64) error {
}
func wechatHook(times int64, err error) {
if err == nil {
return
}
if err != nil {
envi := "测试"
if k8sclient.Environment() == k8sclient.MasterNamespace {
envi = "正式"
@ -153,5 +137,6 @@ func wechatHook(times int64, err error) {
hook = hook.FontColor("完成", wechat.Info)
}
_ = hook.Send()
}
}

Loading…
Cancel
Save