This commit is contained in:
meixiongfeng 2022-07-21 11:58:59 +08:00
commit 3809abc381
11 changed files with 219 additions and 136 deletions

View File

@ -22,7 +22,6 @@ func newClient(options *Options) (sys *Client, err error) {
sys = &Client{ sys = &Client{
options: options, options: options,
metadata: fmt.Sprintf("stag=%s&stype=%s&sid=%s&version=%s&addr=%s", options.ServiceTag, options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr), metadata: fmt.Sprintf("stag=%s&stype=%s&sid=%s&version=%s&addr=%s", options.ServiceTag, options.ServiceType, options.ServiceId, options.ServiceVersion, "tcp@"+options.ServiceAddr),
// clients: make(map[string]client.XClient),
clusterClients: make(map[string]map[string]client.XClient), clusterClients: make(map[string]map[string]client.XClient),
conns: make(map[string]net.Conn), conns: make(map[string]net.Conn),
connecting: make(map[string]struct{}), connecting: make(map[string]struct{}),
@ -37,7 +36,6 @@ type Client struct {
metadata string metadata string
writeTimeout time.Duration writeTimeout time.Duration
AsyncWrite bool AsyncWrite bool
// clients map[string]client.XClient
clusterClients map[string]map[string]client.XClient //其他集群客户端 clusterClients map[string]map[string]client.XClient //其他集群客户端
connsMapMu sync.RWMutex connsMapMu sync.RWMutex
conns map[string]net.Conn conns map[string]net.Conn
@ -52,7 +50,8 @@ type Client struct {
func (this *Client) DoMessage() { func (this *Client) DoMessage() {
for msg := range this.msgChan { for msg := range this.msgChan {
go func(req *protocol.Message) { go func(req *protocol.Message) {
this.Debugf("DoMessage ServicePath:%s ServiceMethod:%s", req.ServicePath, req.ServiceMethod) if req.ServicePath != "" && req.ServiceMethod != "" {
this.Debugf("DoMessage :%v", req)
addr, ok := req.Metadata[ServiceAddrKey] addr, ok := req.Metadata[ServiceAddrKey]
if !ok { if !ok {
this.Errorf("Metadata no found ServiceAddrKey!") this.Errorf("Metadata no found ServiceAddrKey!")
@ -65,6 +64,7 @@ func (this *Client) DoMessage() {
} }
res, _ := this.handleRequest(context.Background(), req) res, _ := this.handleRequest(context.Background(), req)
this.sendResponse(conn, req, res) this.sendResponse(conn, req, res)
}
}(msg) }(msg)
} }
} }
@ -242,6 +242,7 @@ func (this *Client) UpdateServer(servers map[string]*ServiceNode) {
this.connecting[v.ServiceAddr] = struct{}{} this.connecting[v.ServiceAddr] = struct{}{}
this.connectMapMu.Unlock() this.connectMapMu.Unlock()
if err := this.Call(context.Background(), fmt.Sprintf("%s/%s", v.ServiceType, v.ServiceId), RpcX_ShakeHands, &ServiceNode{ if err := this.Call(context.Background(), fmt.Sprintf("%s/%s", v.ServiceType, v.ServiceId), RpcX_ShakeHands, &ServiceNode{
ServiceTag: this.options.ServiceTag,
ServiceId: this.options.ServiceId, ServiceId: this.options.ServiceId,
ServiceType: this.options.ServiceType, ServiceType: this.options.ServiceType,
ServiceAddr: this.options.ServiceAddr}, ServiceAddr: this.options.ServiceAddr},
@ -250,6 +251,8 @@ func (this *Client) UpdateServer(servers map[string]*ServiceNode) {
this.connectMapMu.Lock() this.connectMapMu.Lock()
delete(this.connecting, v.ServiceAddr) delete(this.connecting, v.ServiceAddr)
this.connectMapMu.Unlock() this.connectMapMu.Unlock()
} else {
this.Debugf("UpdateServer addr:%s ", v.ServiceAddr)
} }
} }
} }
@ -262,9 +265,6 @@ func (this *Client) ClientConnected(conn net.Conn) (net.Conn, error) {
this.connsMapMu.Lock() this.connsMapMu.Lock()
this.conns[addr] = conn this.conns[addr] = conn
this.connsMapMu.Unlock() this.connsMapMu.Unlock()
this.connectMapMu.Lock()
delete(this.connecting, addr)
this.connectMapMu.Unlock()
this.Debugf("ClientConnected addr:%v", addr) this.Debugf("ClientConnected addr:%v", addr)
return conn, nil return conn, nil
} }

View File

@ -75,6 +75,7 @@ func (this *Selector) Find(ctx context.Context, servicePath, serviceMethod strin
for i, v := range nodes { for i, v := range nodes {
addrs[i] = v.ServiceAddr addrs[i] = v.ServiceAddr
} }
return addrs
} }
return nil return nil
} }

View File

@ -194,14 +194,83 @@ func (this *Service) ClusterBroadcast(ctx context.Context, servicePath string, s
return return
} }
// func (this *Service) PreReadRequest(ctx context.Context) error {
// var (
// stag string
// selector client.Selector
// ok bool
// )
// req_metadata, ok := ctx.Value(share.ReqMetaDataKey).(map[string]string)
// this.Debugf("PreReadRequest Meta:%v ", ctx.Value(share.ReqMetaDataKey))
// if stag, ok = req_metadata[ServiceClusterTag]; ok {
// if selector, ok = this.selectors[stag]; !ok {
// this.selectors[stag] = newSelector(nil)
// selector = this.selectors[stag]
// }
// if addr, ok := req_metadata[ServiceAddrKey]; ok {
// if _, ok = this.clientmeta[addr]; !ok {
// if smeta, ok := req_metadata[ServiceMetaKey]; ok {
// servers := make(map[string]string)
// this.clientmutex.Lock()
// this.clientmeta[addr] = smeta
// this.clients[addr] = ctx.Value(server.RemoteConnContextKey).(net.Conn)
// for k, v := range this.clientmeta {
// servers[k] = v
// }
// this.clientmutex.Unlock()
// selector.UpdateServer(servers)
// this.Debugf("fond new node addr:%s smeta:%s \n", addr, smeta)
// }
// }
// }
// }
// return nil
// }
//监听客户端链接到服务上 保存客户端的连接对象 //监听客户端链接到服务上 保存客户端的连接对象
func (this *Service) PreHandleRequest(ctx context.Context, r *protocol.Message) error { // func (this *Service) PreHandleRequest(ctx context.Context, r *protocol.Message) error {
// var (
// stag string
// selector client.Selector
// ok bool
// )
// req_metadata := ctx.Value(share.ReqMetaDataKey).(map[string]string)
// this.Debugf("PreHandleRequest ServicePath:%s ServiceMethod:%s Meta:%v ", r.ServicePath, r.ServiceMethod, ctx.Value(share.ReqMetaDataKey))
// if stag, ok = req_metadata[ServiceClusterTag]; ok {
// if selector, ok = this.selectors[stag]; !ok {
// this.selectors[stag] = newSelector(nil)
// selector = this.selectors[stag]
// }
// if addr, ok := req_metadata[ServiceAddrKey]; ok {
// if _, ok = this.clientmeta[addr]; !ok {
// if smeta, ok := req_metadata[ServiceMetaKey]; ok {
// servers := make(map[string]string)
// this.clientmutex.Lock()
// this.clientmeta[addr] = smeta
// this.clients[addr] = ctx.Value(server.RemoteConnContextKey).(net.Conn)
// for k, v := range this.clientmeta {
// servers[k] = v
// }
// this.clientmutex.Unlock()
// selector.UpdateServer(servers)
// this.Debugf("fond new node addr:%s smeta:%s \n", addr, smeta)
// }
// }
// }
// }
// return nil
// }
//监控rpc连接收到的请求消息 处理消息回调请求
func (this *Service) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error {
if isCallMessage := (r.MessageType() == protocol.Request); isCallMessage {
var ( var (
stag string stag string
selector client.Selector selector client.Selector
ok bool ok bool
) )
req_metadata := ctx.Value(share.ReqMetaDataKey).(map[string]string) req_metadata := r.Metadata
this.Debugf("PreReadRequest ServicePath:%s ServicePath:%s Metadata:%v ", r.ServicePath, r.ServiceMethod, r.Metadata)
if stag, ok = req_metadata[ServiceClusterTag]; ok { if stag, ok = req_metadata[ServiceClusterTag]; ok {
if selector, ok = this.selectors[stag]; !ok { if selector, ok = this.selectors[stag]; !ok {
this.selectors[stag] = newSelector(nil) this.selectors[stag] = newSelector(nil)
@ -226,12 +295,6 @@ func (this *Service) PreHandleRequest(ctx context.Context, r *protocol.Message)
} }
return nil return nil
} }
//监控rpc连接收到的请求消息 处理消息回调请求
func (this *Service) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error {
if isCallMessage := (r.MessageType() == protocol.Request); isCallMessage {
return nil
}
e = errors.New("is callMessage") e = errors.New("is callMessage")
seq := r.Seq() seq := r.Seq()
this.mutex.Lock() this.mutex.Lock()
@ -326,8 +389,8 @@ func (this *Service) call(ctx context.Context, clusterTag string, servicePath st
selector client.Selector selector client.Selector
ok bool ok bool
) )
if servicePath == "" { if clusterTag == "" || servicePath == "" {
err = errors.New("servicePath no cant null") err = fmt.Errorf("clusterTag:%s servicePath:%s no cant null", clusterTag, servicePath)
return return
} }
metadata = map[string]string{ metadata = map[string]string{

View File

@ -12,7 +12,9 @@ import (
//参数校验 //参数校验
func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode) { func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode) {
if (req.Channel == pb.ChatChannel_Union && req.TargetId == "") || (req.Channel == pb.ChatChannel_Private && req.TargetId == "") {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
@ -25,7 +27,9 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
user *pb.DBUser user *pb.DBUser
max_chat int32 max_chat int32
) )
if code = this.SendCheck(session, req); code != pb.ErrorCode_Success {
return
}
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
this.module.Errorf("GetUser is nill") this.module.Errorf("GetUser is nill")
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
@ -54,7 +58,10 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
this.module.PushWorld(msg) if err = this.module.PushWorld(msg); err != nil {
code = pb.ErrorCode_DBError
return
}
break break
case pb.ChatChannel_Union: case pb.ChatChannel_Union:
msg.UnionId = req.TargetId msg.UnionId = req.TargetId
@ -62,11 +69,17 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
this.module.PushUnion(msg) if err = this.module.PushUnion(req.TargetId, msg); err != nil {
code = pb.ErrorCode_DBError
return
}
break break
case pb.ChatChannel_Private: case pb.ChatChannel_Private:
msg.Ruid = req.TargetId msg.Ruid = req.TargetId
this.module.PushUser(msg) if err = this.module.PushUser(msg); err != nil {
code = pb.ErrorCode_DBError
return
}
break break
} }
session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{}) session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{})

View File

@ -64,38 +64,39 @@ func (this *Chat) EventUserOffline(session comm.IUserSession) {
//Push-------------------------------------------------------------------------------------------------------------- //Push--------------------------------------------------------------------------------------------------------------
//推送消息到世界 //推送消息到世界
func (this *Chat) PushWorld(msg *pb.DBChat) { func (this *Chat) PushWorld(msg *pb.DBChat) (err error) {
var ( var (
err error
reply *pb.RPCMessageReply reply *pb.RPCMessageReply
) )
reply = &pb.RPCMessageReply{} reply = &pb.RPCMessageReply{}
data, _ := anypb.New(msg) data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
if err = this.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ if err = this.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
MainType: string(this.GetType()), MainType: string(this.GetType()),
SubType: "push", SubType: "message",
Data: data, Data: data,
}, reply); err != nil { }, reply); err != nil {
this.Errorf("err:%v", err) this.Errorf("err:%v", err)
} }
return
} }
//推送消息到工会 //推送消息到工会
func (this *Chat) PushUnion(msg *pb.DBChat) { func (this *Chat) PushUnion(unionId string, msg *pb.DBChat) (err error) {
return
} }
//推送消息到用户 //推送消息到用户
func (this *Chat) PushUser(msg *pb.DBChat) { func (this *Chat) PushUser(msg *pb.DBChat) (err error) {
if session, ok := this.GetUserSession(msg.Ruid); ok { if session, ok := this.GetUserSession(msg.Ruid); ok {
session.SendMsg(string(this.GetType()), "push", msg) session.SendMsg(string(this.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
if err := session.Push(); err != nil { if err = session.Push(); err != nil {
this.Errorf("err:%v", err) this.Errorf("err:%v", err)
} }
return return
} else { } else {
this.modelChat.SaveUserMsg(msg) err = this.modelChat.SaveUserMsg(msg)
} }
return
} }
//全集群推送 //全集群推送
@ -105,7 +106,7 @@ func (this *Chat) PushToUsers(group, channel int32, msg *pb.DBChat) {
users []*pb.CacheUser users []*pb.CacheUser
) )
if users, err = this.modelChat.GetCrossChannelMember(group, channel); err == nil { if users, err = this.modelChat.GetCrossChannelMember(group, channel); err == nil {
if err = this.SendMsgToUsers(string(this.GetType()), "push", msg, users...); err != nil { if err = this.SendMsgToUsers(string(this.GetType()), "message", &pb.ChatMessagePush{Chat: msg}, users...); err != nil {
this.Errorf("err:%v", err) this.Errorf("err:%v", err)
return return
} }
@ -119,10 +120,10 @@ func (this *Chat) PushAllWorld(msg *pb.DBChat) {
reply *pb.RPCMessageReply reply *pb.RPCMessageReply
) )
reply = &pb.RPCMessageReply{} reply = &pb.RPCMessageReply{}
data, _ := anypb.New(msg) data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
if err = this.service.ClusterBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ if err = this.service.ClusterBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
MainType: string(this.GetType()), MainType: string(this.GetType()),
SubType: "push", SubType: "message",
Data: data, Data: data,
}, reply); err != nil { }, reply); err != nil {
this.Errorf("err:%v", err) this.Errorf("err:%v", err)

View File

@ -21,6 +21,7 @@ type AgentMgrComp struct {
cbase.ModuleCompBase cbase.ModuleCompBase
options *Options options *Options
service base.IRPCXService service base.IRPCXService
module *Gateway
agents *sync.Map agents *sync.Map
} }
@ -28,6 +29,7 @@ func (this *AgentMgrComp) Init(service core.IService, module core.IModule, comp
err = this.ModuleCompBase.Init(service, module, comp, options) err = this.ModuleCompBase.Init(service, module, comp, options)
this.options = options.(*Options) this.options = options.(*Options)
this.service = service.(base.IRPCXService) this.service = service.(base.IRPCXService)
this.module = module.(*Gateway)
this.agents = new(sync.Map) this.agents = new(sync.Map)
return return
} }
@ -88,6 +90,7 @@ func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq,
// SendMsgToAgent 向用户发送消息 // SendMsgToAgent 向用户发送消息
func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error { func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error {
this.module.Debugf("SendMsgToAgent: agent:%s msg:%v", args.UserSessionId, args.Reply)
if a, ok := this.agents.Load(args.UserSessionId); ok { if a, ok := this.agents.Load(args.UserSessionId); ok {
for _, v := range args.Reply { for _, v := range args.Reply {
a.(IAgent).WriteMsg(v) a.(IAgent).WriteMsg(v)
@ -106,6 +109,7 @@ func (this *AgentMgrComp) SendMsgToAgents(ctx context.Context, args *pb.BatchMes
SubType: args.SubType, SubType: args.SubType,
Data: args.Data, Data: args.Data,
} }
this.module.Debugf("SendMsgToAgents: agents:%v msg:%v", args.UserSessionIds, msg)
for _, v := range args.UserSessionIds { for _, v := range args.UserSessionIds {
if a, ok := this.agents.Load(v); ok { if a, ok := this.agents.Load(v); ok {
a.(IAgent).WriteMsg(msg) a.(IAgent).WriteMsg(msg)
@ -121,6 +125,7 @@ func (this *AgentMgrComp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadC
SubType: args.SubType, SubType: args.SubType,
Data: args.Data, Data: args.Data,
} }
this.module.Debugf("SendMsgToAllAgent: msg:%v", msg)
this.agents.Range(func(key, value any) bool { this.agents.Range(func(key, value any) bool {
value.(IAgent).WriteMsg(msg) value.(IAgent).WriteMsg(msg)
return true return true

View File

@ -82,6 +82,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
err = this.module.modelSession.Change(user.Uid, map[string]interface{}{ err = this.module.modelSession.Change(user.Uid, map[string]interface{}{
"uid": user.Uid, "uid": user.Uid,
"sessionId": session.GetSessionId(), "sessionId": session.GetSessionId(),
"serviceTag": session.GetServiecTag(),
"gatewayServiceId": session.GetGatewayServiceId(), "gatewayServiceId": session.GetGatewayServiceId(),
"ip": session.GetIP(), "ip": session.GetIP(),
}, },

View File

@ -26,7 +26,7 @@ type ChatMessagePush struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Chats []*DBChat `protobuf:"bytes,1,rep,name=chats,proto3" json:"chats"` Chat *DBChat `protobuf:"bytes,1,opt,name=chat,proto3" json:"chat"`
} }
func (x *ChatMessagePush) Reset() { func (x *ChatMessagePush) Reset() {
@ -61,9 +61,9 @@ func (*ChatMessagePush) Descriptor() ([]byte, []int) {
return file_chat_chat_msg_proto_rawDescGZIP(), []int{0} return file_chat_chat_msg_proto_rawDescGZIP(), []int{0}
} }
func (x *ChatMessagePush) GetChats() []*DBChat { func (x *ChatMessagePush) GetChat() *DBChat {
if x != nil { if x != nil {
return x.Chats return x.Chat
} }
return nil return nil
} }
@ -662,55 +662,55 @@ var File_chat_chat_msg_proto protoreflect.FileDescriptor
var file_chat_chat_msg_proto_rawDesc = []byte{ var file_chat_chat_msg_proto_rawDesc = []byte{
0x0a, 0x13, 0x63, 0x68, 0x61, 0x74, 0x2f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x0a, 0x13, 0x63, 0x68, 0x61, 0x74, 0x2f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x6d, 0x73, 0x67, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x63, 0x68, 0x61, 0x74, 0x2f, 0x63, 0x68, 0x61, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x63, 0x68, 0x61, 0x74, 0x2f, 0x63, 0x68, 0x61, 0x74,
0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x30, 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2e, 0x0a, 0x0f, 0x43, 0x68, 0x61,
0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x05, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b, 0x0a, 0x04,
0x63, 0x68, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x43,
0x68, 0x61, 0x74, 0x52, 0x04, 0x63, 0x68, 0x61, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x68, 0x61,
0x74, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71,
0x22, 0x34, 0x0a, 0x14, 0x43, 0x68, 0x61, 0x74, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61,
0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61,
0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x35, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68,
0x61, 0x6e, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x12,
0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x4e, 0x0a,
0x16, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e,
0x65, 0x6c, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x18,
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x22, 0x38, 0x0a,
0x0e, 0x43, 0x68, 0x61, 0x74, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12,
0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e,
0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07,
0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x22, 0x30, 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x74, 0x47,
0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x05, 0x63, 0x68,
0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x43, 0x68,
0x61, 0x74, 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0x5a, 0x0a, 0x12, 0x43, 0x68, 0x61,
0x74, 0x53, 0x70, 0x61, 0x6e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12,
0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e,
0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07,
0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e,
0x65, 0x6c, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x34, 0x0a, 0x13, 0x43, 0x68, 0x61, 0x74, 0x53, 0x70, 0x61,
0x6e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x05,
0x63, 0x68, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x63, 0x68, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42,
0x43, 0x68, 0x61, 0x74, 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x43, 0x68, 0x61, 0x74, 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0x6b, 0x0a, 0x0b, 0x43,
0x68, 0x61, 0x74, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x68, 0x61, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x68,
0x65, 0x71, 0x22, 0x34, 0x0a, 0x14, 0x43, 0x68, 0x61, 0x74, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43, 0x68,
0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x18, 0x02,
0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x35, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x74, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x18,
0x43, 0x68, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x71, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x01, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x74,
0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x53, 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x74,
0x4e, 0x0a, 0x16, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x43, 0x68, 0x53, 0x70, 0x61, 0x6e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x07, 0x63,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43,
0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x53, 0x75, 0x63, 0x6e, 0x65, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02,
0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x22, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x12, 0x0a,
0x38, 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x74, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x10, 0x43, 0x68, 0x61, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73,
0x71, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x33,
0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x22, 0x30, 0x0a, 0x0f, 0x43, 0x68, 0x61,
0x74, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x05,
0x63, 0x68, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42,
0x43, 0x68, 0x61, 0x74, 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0x5a, 0x0a, 0x12, 0x43,
0x68, 0x61, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
0x71, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c,
0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61,
0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x34, 0x0a, 0x13, 0x43, 0x68, 0x61, 0x74, 0x53,
0x70, 0x61, 0x6e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d,
0x0a, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e,
0x44, 0x42, 0x43, 0x68, 0x61, 0x74, 0x52, 0x05, 0x63, 0x68, 0x61, 0x74, 0x73, 0x22, 0x6b, 0x0a,
0x0b, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x07,
0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e,
0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61,
0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64,
0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x43, 0x68,
0x61, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x53, 0x0a, 0x0f, 0x43, 0x68,
0x61, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a,
0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c,
0x2e, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x07, 0x63, 0x68,
0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22,
0x12, 0x0a, 0x10, 0x43, 0x68, 0x61, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x53, 0x65, 0x6e, 0x64, 0x52,
0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (
@ -744,7 +744,7 @@ var file_chat_chat_msg_proto_goTypes = []interface{}{
(ChatChannel)(0), // 14: ChatChannel (ChatChannel)(0), // 14: ChatChannel
} }
var file_chat_chat_msg_proto_depIdxs = []int32{ var file_chat_chat_msg_proto_depIdxs = []int32{
13, // 0: ChatMessagePush.chats:type_name -> DBChat 13, // 0: ChatMessagePush.chat:type_name -> DBChat
14, // 1: ChatGetListReq.channel:type_name -> ChatChannel 14, // 1: ChatGetListReq.channel:type_name -> ChatChannel
13, // 2: ChatGetListResp.chats:type_name -> DBChat 13, // 2: ChatGetListResp.chats:type_name -> DBChat
14, // 3: ChatSpanGetListReq.channel:type_name -> ChatChannel 14, // 3: ChatSpanGetListReq.channel:type_name -> ChatChannel

View File

@ -4,7 +4,7 @@ import "chat/chat_db.proto";
// //
message ChatMessagePush{ message ChatMessagePush{
repeated DBChat chats = 1; DBChat chat = 1;
} }
// //

View File

@ -2,12 +2,11 @@ syntax = "proto3";
option go_package = ".;pb"; option go_package = ".;pb";
message CacheUser { message CacheUser {
string uid = 1; //id string uid = 1; //@go_tags(`json:"uid"`) id
string SessionId = 2; //id string SessionId = 2; //@go_tags(`json:"sessionId"`) id
string ServiceTag = 3; // id string ServiceTag = 3; //@go_tags(`json:"serviceTag"`) id
string GatewayServiceId = 4; //id string GatewayServiceId = 4; //@go_tags(`json:"gatewayServiceId"`) id
string ip = 5; //ip string ip = 5; //@go_tags(`json:"ip"`) ip
// DB_UserData UserData = 4; //@go_tags(`json:",inline"`)
} }
message DBUser { message DBUser {

View File

@ -26,9 +26,9 @@ type CacheUser struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id
SessionId string `protobuf:"bytes,2,opt,name=SessionId,proto3" json:"SessionId"` //会话id SessionId string `protobuf:"bytes,2,opt,name=SessionId,proto3" json:"sessionId"` //会话id
ServiceTag string `protobuf:"bytes,3,opt,name=ServiceTag,proto3" json:"ServiceTag"` //所在服务集群 区服id ServiceTag string `protobuf:"bytes,3,opt,name=ServiceTag,proto3" json:"serviceTag"` //所在服务集群 区服id
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId"` //所在网关服务id GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"gatewayServiceId"` //所在网关服务id
Ip string `protobuf:"bytes,5,opt,name=ip,proto3" json:"ip"` //远程ip Ip string `protobuf:"bytes,5,opt,name=ip,proto3" json:"ip"` //远程ip
} }