mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-28 21:19:02 +08:00
cache
This commit is contained in:
parent
0b4ba548a5
commit
bbc3f5c19a
@ -7,6 +7,7 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
cacheRpc "Open_IM/pkg/proto/cache"
|
cacheRpc "Open_IM/pkg/proto/cache"
|
||||||
|
pbCache "Open_IM/pkg/proto/cache"
|
||||||
pbChat "Open_IM/pkg/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
pbConversation "Open_IM/pkg/proto/conversation"
|
pbConversation "Open_IM/pkg/proto/conversation"
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
@ -216,28 +217,35 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg result", canSend, "end rpc and return")
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg result", canSend, "end rpc and return")
|
||||||
return returnMsg(&replay, pb, 201, "callbackBeforeSendGroupMsg result stop rpc and return", "", 0)
|
return returnMsg(&replay, pb, 201, "callbackBeforeSendGroupMsg result stop rpc and return", "", 0)
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
//etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
//client := pbGroup.NewGroupClient(etcdConn)
|
||||||
req := &pbGroup.GetGroupAllMemberReq{
|
//req := &pbGroup.GetGroupAllMemberReq{
|
||||||
GroupID: pb.MsgData.GroupID,
|
// GroupID: pb.MsgData.GroupID,
|
||||||
OperationID: pb.OperationID,
|
// OperationID: pb.OperationID,
|
||||||
}
|
//}
|
||||||
reply, err := client.GetGroupAllMember(context.Background(), req)
|
//reply, err := client.GetGroupAllMember(context.Background(), req)
|
||||||
|
//if err != nil {
|
||||||
|
// log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error())
|
||||||
|
// return returnMsg(&replay, pb, 201, err.Error(), "", 0)
|
||||||
|
//}
|
||||||
|
//if reply.ErrCode != 0 {
|
||||||
|
// log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg)
|
||||||
|
// return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0)
|
||||||
|
//}
|
||||||
|
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pb.OperationID, GroupID: pb.MsgData.GroupID}
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||||
|
client := pbCache.NewCacheClient(etcdConn)
|
||||||
|
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error())
|
log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||||
return returnMsg(&replay, pb, 201, err.Error(), "", 0)
|
return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache failed", "", 0)
|
||||||
}
|
}
|
||||||
if reply.ErrCode != 0 {
|
if cacheResp.CommonResp.ErrCode != 0 {
|
||||||
log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg)
|
log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||||
return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0)
|
||||||
}
|
}
|
||||||
memberUserIDList := func(all []*sdk_ws.GroupMemberFullInfo) (result []string) {
|
memberUserIDList := cacheResp.UserIDList
|
||||||
for _, v := range all {
|
log.Debug(pb.OperationID, "GetGroupAllMember userID list", cacheResp.UserIDList)
|
||||||
result = append(result, v.UserID)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}(reply.MemberList)
|
|
||||||
log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList)
|
|
||||||
var addUidList []string
|
var addUidList []string
|
||||||
switch pb.MsgData.ContentType {
|
switch pb.MsgData.ContentType {
|
||||||
case constant.MemberKickedNotification:
|
case constant.MemberKickedNotification:
|
||||||
|
@ -233,7 +233,7 @@ func (d *DataBases) AddGroupMemberToCache(groupID string, userIDList ...string)
|
|||||||
for _, id := range userIDList {
|
for _, id := range userIDList {
|
||||||
IDList = append(IDList, id)
|
IDList = append(IDList, id)
|
||||||
}
|
}
|
||||||
_, err := d.Exec("SADD", blackListCache+groupID, IDList...)
|
_, err := d.Exec("SADD", groupCache+groupID, IDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ func (d *DataBases) ReduceGroupMemberFromCache(groupID string, userIDList ...str
|
|||||||
for _, id := range userIDList {
|
for _, id := range userIDList {
|
||||||
IDList = append(IDList, id)
|
IDList = append(IDList, id)
|
||||||
}
|
}
|
||||||
_, err := d.Exec("SREM", blackListCache+groupID, IDList...)
|
_, err := d.Exec("SREM", groupCache+groupID, IDList...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user