otto 1 year ago
parent
commit
6ec57721dc
  1. 4
      go.mod
  2. 22
      job-dev.yaml
  3. 4
      job-master.yaml
  4. 12
      task/task.go

4
go.mod

@ -3,8 +3,8 @@ module git.gz.internal.jumaiyx.cn/job/hotspot_queue
go 1.20
require (
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20231031083052-76fc676bf524
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20231031080505-e9d6750fb998
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20231119073502-4f6bb5e43b0b
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20231123090823-91017d7a1a1e
git.gz.internal.jumaiyx.cn/pkg/config/v2 v2.0.0-20231031123738-f6698f93632e
git.gz.internal.jumaiyx.cn/pkg/jtime v0.0.0-20230627153611-5d9e320123cc
github.com/redis/go-redis/v9 v9.3.0

22
job-dev.yaml

@ -0,0 +1,22 @@
apiVersion: batch/v1
kind: Job
metadata:
name: hotspot-queue-job
namespace: master
spec:
schedule: "0 1 * * *"
parallelism: 1
template:
metadata:
name: hotspot-queue-job
spec:
containers:
- name: hotspot-queue-job
image: harbor.homieyy.com/job/master/hotspot-queue:3defe42b9ebcb87c67f99daa64f53beb7951b35d
# command: ["./main"]
env:
- name: JM_ENVIRONMENT
value: master
restartPolicy: OnFailure
imagePullSecrets:
- name: registry-harbor

4
job-master.yaml

@ -11,8 +11,8 @@ spec:
spec:
containers:
- name: hotspot-queue-job
image: harbor.homieyy.com/job/master/hotspot-queue:04581463b6917ace4405069e132d6edca8433c6d
command: ["./main"]
image: harbor.homieyy.com/job/master/hotspot-queue:3defe42b9ebcb87c67f99daa64f53beb7951b35d
# command: ["./main"]
env:
- name: JM_ENVIRONMENT
value: master

12
task/task.go

@ -72,12 +72,13 @@ func NewTask() {
)
now := time.Now()
// 获取房间信息
roomClientV2, err := client.GetRoomClientV2(ctx)
roomClientV2, roomClientV2Close, err := client.GetRoomClientV2(ctx)
//roomClientV2, err := client.GetRoomClientLocalV2("127.0.0.1:9001")
if err != nil {
fmt.Println("获取房间服务失败:", err.Error())
continue
}
defer roomClientV2Close()
roomRsp, err := roomClientV2.GetRoom(ctx, &v2.GetRoomReq{
RoomId: roomId,
})
@ -94,12 +95,13 @@ func NewTask() {
// 获取房间初始值
value = 100
liveClientV2, err := client.GetLiveClient(ctx)
liveClient, liveClientClose, err := client.GetLiveClient(ctx)
if err != nil {
fmt.Println("获取直播服务失败:", err.Error())
continue
}
defaultHotValueResp, err := liveClientV2.GetDefaultHotValueList(ctx, &livev1.GetDefaultHotValueListReq{
defer liveClientClose()
defaultHotValueResp, err := liveClient.GetDefaultHotValueList(ctx, &livev1.GetDefaultHotValueListReq{
RoomList: []int64{roomId},
})
if err != nil {
@ -128,11 +130,12 @@ func NewTask() {
startTime := prevWeekTime.UnixMilli()
// 获取房间总流水
giftClient, err := client.GetGiftClient(ctx)
giftClient, giftClientClose, err := client.GetGiftClient(ctx)
if err != nil {
fmt.Println("获取礼物服务失败:", err.Error())
continue
}
defer giftClientClose()
giftRsp, err := giftClient.QueryGiveRoomGift(ctx, &giftv1.QueryGiveRoomGiftReq{
RoomIdList: []int64{roomId},
CreateAtStart: &startTime,
@ -189,5 +192,4 @@ func NewTask() {
continue
}
}
//fmt.Println("结束")
}

Loading…
Cancel
Save