随机任务跨服适配调整

This commit is contained in:
liwei1dao 2022-10-27 11:49:44 +08:00
parent 4b001cd62e
commit 67b74f7249
3 changed files with 47 additions and 65 deletions

View File

@ -73,16 +73,17 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
//随机任务 //随机任务
if _, err = this.service.AcrossClusterRpcGo( // if _, err = this.service.AcrossClusterRpcGo(
context.Background(), // context.Background(),
session.GetServiecTag(), // session.GetServiecTag(),
comm.Service_Worker, // comm.Service_Worker,
string(comm.Rpc_ModuleRtaskSendTask), // string(comm.Rpc_ModuleRtaskSendTask),
pb.RPCRTaskReq{Uid: session.GetUserId(), TaskType: int32(comm.Rtype62), Param1: 1}, // pb.RPCRTaskReq{Uid: session.GetUserId(), TaskType: int32(comm.Rtype62), Param1: 1},
nil); err != nil { // nil); err != nil {
this.module.Errorln(err) // this.module.Errorln(err)
} // }
break break
case pb.ChatChannel_Union: case pb.ChatChannel_Union:
msg.UnionId = req.TargetId msg.UnionId = req.TargetId

View File

@ -209,6 +209,20 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
} }
func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) { func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
if this.IsCross() {
//随机任务
if _, err := this.service.AcrossClusterRpcGo(
context.Background(),
session.GetServiecTag(),
comm.Service_Worker,
string(comm.Rpc_ModuleRtaskSendTask),
pb.RPCRTaskReq{Uid: session.GetUserId(), TaskType: int32(rtaskType), Param: params},
nil); err != nil {
this.Errorln(err)
}
return
}
this.Debug("任务事件触发", log.Field{"uid", session.GetUserId()}, log.Field{"taskType", rtaskType}, log.Field{"params", params}) this.Debug("任务事件触发", log.Field{"uid", session.GetUserId()}, log.Field{"taskType", rtaskType}, log.Field{"params", params})
var ( var (
err error err error
@ -335,11 +349,16 @@ func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.R
return return
} }
if this.IsCross() {
err = errors.New("环境错误 此处为跨服环境!")
return
}
if session, ok := this.GetUserSession(args.Uid); !ok { if session, ok := this.GetUserSession(args.Uid); !ok {
err = fmt.Errorf("未查询到用户:%s在线信息!", args.Uid) err = fmt.Errorf("未查询到用户:%s在线信息!", args.Uid)
return return
} else { } else {
this.SendToRtask(session, comm.TaskType(args.TaskType), args.Param1, args.Param2, args.Param3, args.Param4, args.Param5) this.SendToRtask(session, comm.TaskType(args.TaskType), args.Param...)
session.Push() session.Push()
} }
return return

View File

@ -1436,13 +1436,9 @@ type RPCRTaskReq struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
TaskType int32 `protobuf:"varint,2,opt,name=taskType,proto3" json:"taskType"` TaskType int32 `protobuf:"varint,2,opt,name=taskType,proto3" json:"taskType"`
Param1 int32 `protobuf:"varint,3,opt,name=param1,proto3" json:"param1"` Param []int32 `protobuf:"varint,3,rep,packed,name=param,proto3" json:"param"`
Param2 int32 `protobuf:"varint,4,opt,name=param2,proto3" json:"param2"`
Param3 int32 `protobuf:"varint,5,opt,name=param3,proto3" json:"param3"`
Param4 int32 `protobuf:"varint,6,opt,name=param4,proto3" json:"param4"`
Param5 int32 `protobuf:"varint,7,opt,name=param5,proto3" json:"param5"`
} }
func (x *RPCRTaskReq) Reset() { func (x *RPCRTaskReq) Reset() {
@ -1491,39 +1487,11 @@ func (x *RPCRTaskReq) GetTaskType() int32 {
return 0 return 0
} }
func (x *RPCRTaskReq) GetParam1() int32 { func (x *RPCRTaskReq) GetParam() []int32 {
if x != nil { if x != nil {
return x.Param1 return x.Param
} }
return 0 return nil
}
func (x *RPCRTaskReq) GetParam2() int32 {
if x != nil {
return x.Param2
}
return 0
}
func (x *RPCRTaskReq) GetParam3() int32 {
if x != nil {
return x.Param3
}
return 0
}
func (x *RPCRTaskReq) GetParam4() int32 {
if x != nil {
return x.Param4
}
return 0
}
func (x *RPCRTaskReq) GetParam5() int32 {
if x != nil {
return x.Param5
}
return 0
} }
var File_comm_proto protoreflect.FileDescriptor var File_comm_proto protoreflect.FileDescriptor
@ -1665,23 +1633,17 @@ var file_comm_proto_rawDesc = []byte{
0x61, 0x72, 0x61, 0x6d, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x18, 0x61, 0x72, 0x61, 0x6d, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x12, 0x16, 0x0a, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x12, 0x16, 0x0a,
0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70,
0x61, 0x72, 0x61, 0x6d, 0x34, 0x22, 0xb3, 0x01, 0x0a, 0x0b, 0x52, 0x50, 0x43, 0x52, 0x54, 0x61, 0x61, 0x72, 0x61, 0x6d, 0x34, 0x22, 0x51, 0x0a, 0x0b, 0x52, 0x50, 0x43, 0x52, 0x54, 0x61, 0x73,
0x73, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79,
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79,
0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x31, 0x18, 0x03, 0x20, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x03, 0x20, 0x03, 0x28,
0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x31, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x05, 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f,
0x61, 0x72, 0x61, 0x6d, 0x32, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x61, 0x72, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06,
0x61, 0x6d, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x18, 0x05, 0x20, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12,
0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65,
0x61, 0x72, 0x61, 0x6d, 0x34, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x61, 0x72, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a,
0x61, 0x6d, 0x34, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x35, 0x18, 0x07, 0x20, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x35, 0x2a, 0x43, 0x0a, 0x12, 0x48,
0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70,
0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b,
0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53,
0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (