diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index b9bcd6681..7b75efa90 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -43,6 +43,8 @@ func main() { userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1 userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1 userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache) + userRouterGroup.POST("/get_user_friend_from_cache", user.GetFriendIDListFromCache) + userRouterGroup.POST("/get_black_list_from_cache", user.GetBlackIDListFromCache) } //friend routing group friendRouterGroup := r.Group("/friend") diff --git a/internal/api/office/work_moments.go b/internal/api/office/work_moments.go index 4b1f211d5..0535feee5 100644 --- a/internal/api/office/work_moments.go +++ b/internal/api/office/work_moments.go @@ -267,7 +267,7 @@ func GetUserWorkMoments(c *gin.Context) { UserID: comment.UserID, UserName: comment.UserName, ReplyUserID: comment.ReplyUserID, - ReplyUserName: comment.ReplyUserID, + ReplyUserName: comment.ReplyUserName, ContentID: comment.ContentID, Content: comment.Content, CreateTime: comment.CreateTime, @@ -350,7 +350,7 @@ func GetUserFriendWorkMoments(c *gin.Context) { UserID: comment.UserID, UserName: comment.UserName, ReplyUserID: comment.ReplyUserID, - ReplyUserName: comment.ReplyUserID, + ReplyUserName: comment.ReplyUserName, ContentID: comment.ContentID, Content: comment.Content, CreateTime: comment.CreateTime, diff --git a/internal/api/user/user.go b/internal/api/user/user.go index 437774972..41042099e 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -8,6 +8,7 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/common/token_verify" "Open_IM/pkg/grpc-etcdv3/getcdv3" + cacheRpc "Open_IM/pkg/proto/cache" pbRelay "Open_IM/pkg/proto/relay" open_im_sdk "Open_IM/pkg/proto/sdk_ws" rpc "Open_IM/pkg/proto/user" @@ -18,6 +19,44 @@ import ( "strings" ) +func GetUsersInfoFromCache(c *gin.Context) { + params := api.GetUsersInfoReq{} + if err := c.BindJSON(¶ms); err != nil { + log.NewError("0", "BindJSON failed ", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()}) + return + } + req := &rpc.GetUserInfoReq{} + utils.CopyStructFields(req, ¶ms) + var ok bool + ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + if !ok { + log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + return + } + log.NewInfo(params.OperationID, "GetUserInfo args ", req.String()) + + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + client := rpc.NewUserClient(etcdConn) + RpcResp, err := client.GetUserInfo(context.Background(), req) + if err != nil { + log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) + return + } + var publicUserInfoList []*open_im_sdk.PublicUserInfo + for _, v := range RpcResp.UserInfoList { + publicUserInfoList = append(publicUserInfoList, + &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex}) + } + + resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList} + resp.Data = jsonData.JsonDataList(resp.UserInfoList) + log.NewInfo(req.OperationID, "GetUserInfo api return ", resp) + c.JSON(http.StatusOK, resp) +} + //func GetUsersInfoFromCache(c *gin.Context) { // params := api.GetUsersInfoReq{} // if err := c.BindJSON(¶ms); err != nil { @@ -35,13 +74,13 @@ import ( // return // } // log.NewInfo(params.OperationID, "GetUserInfo args ", getUserInfoReq.String()) -// reqCacheGetUserInfo := &cacheRpc.GetUserInfoReq{} +// reqCacheGetUserInfo := &cacheRpc.GetUserInfoFromCacheReq{} // utils.CopyStructFields(reqCacheGetUserInfo, ¶ms) // var userInfoList []*open_im_sdk.UserInfo // var publicUserInfoList []*open_im_sdk.PublicUserInfo // etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) // cacheClient := cacheRpc.NewCacheClient(etcdConn) -// cacheResp, err := cacheClient.GetUserInfo(context.Background(), reqCacheGetUserInfo) +// cacheResp, err := cacheClient.GetUserInfoFromCache(context.Background(), reqCacheGetUserInfo) // if err != nil { // log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", err.Error()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed: " + err.Error()}) @@ -101,11 +140,11 @@ import ( // return // } // userInfoList = append(userInfoList, rpcResp.UserInfoList...) -// cacheUpdateUserInfoReq := &cacheRpc.UpdateUserInfoReq{ +// cacheUpdateUserInfoReq := &cacheRpc.UpdateUserInfoToCacheReq{ // UserInfoList: rpcResp.UserInfoList, // OperationID: getUserInfoReq.OperationID, // } -// _, err = cacheClient.UpdateUserInfo(context.Background(), cacheUpdateUserInfoReq) +// _, err = cacheClient.UpdateUserInfoToCache(context.Background(), cacheUpdateUserInfoReq) // if err != nil { // log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error()) // c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()}) @@ -122,50 +161,70 @@ import ( // c.JSON(http.StatusOK, resp) //} -func GetUsersInfoFromCache(c *gin.Context) { - params := api.GetUsersInfoReq{} - if err := c.BindJSON(¶ms); err != nil { - log.NewError("0", "BindJSON failed ", err.Error()) +func GetFriendIDListFromCache(c *gin.Context) { + var ( + req api.GetFriendIDListFromCacheReq + resp api.GetFriendIDListFromCacheResp + reqPb cacheRpc.GetFriendIDListFromCacheReq + respPb *cacheRpc.GetFriendIDListFromCacheResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, "BindJSON failed ", err.Error()) c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()}) return } - req := &rpc.GetUserInfoReq{} - utils.CopyStructFields(req, ¶ms) + reqPb.OperationID = req.OperationID var ok bool - ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + ok, reqPb.UserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) if !ok { log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) return } - log.NewInfo(params.OperationID, "GetUserInfo args ", req.String()) - - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) - client := rpc.NewUserClient(etcdConn) - RpcResp, err := client.GetUserInfo(context.Background(), req) + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + client := cacheRpc.NewCacheClient(etcdConn) + respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb) if err != nil { - log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String()) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()}) return } - var publicUserInfoList []*open_im_sdk.PublicUserInfo - for _, v := range RpcResp.UserInfoList { - publicUserInfoList = append(publicUserInfoList, - &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex}) - } - - resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList} - resp.Data = jsonData.JsonDataList(resp.UserInfoList) - log.NewInfo(req.OperationID, "GetUserInfo api return ", resp) + resp.UserIDList = respPb.UserIDList + resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode} c.JSON(http.StatusOK, resp) } -func GetUserFriendFromCache(c *gin.Context) { - -} - -func GetBlackListFromCache(c *gin.Context) { - +func GetBlackIDListFromCache(c *gin.Context) { + var ( + req api.GetBlackIDListFromCacheReq + resp api.GetBlackIDListFromCacheResp + reqPb cacheRpc.GetBlackIDListFromCacheReq + respPb *cacheRpc.GetBlackIDListFromCacheResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, "BindJSON failed ", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()}) + return + } + reqPb.OperationID = req.OperationID + var ok bool + ok, reqPb.UserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + if !ok { + log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token")) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + return + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + client := cacheRpc.NewCacheClient(etcdConn) + respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()}) + return + } + resp.UserIDList = respPb.UserIDList + resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode} + c.JSON(http.StatusOK, resp) } func GetUsersInfo(c *gin.Context) { diff --git a/internal/msg_transfer/logic/history_msg_handler.go b/internal/msg_transfer/logic/history_msg_handler.go index 0b9f5c1c3..f7acea5d6 100644 --- a/internal/msg_transfer/logic/history_msg_handler.go +++ b/internal/msg_transfer/logic/history_msg_handler.go @@ -14,6 +14,7 @@ import ( "github.com/Shopify/sarama" "github.com/golang/protobuf/proto" "strings" + "time" ) type fcb func(msg []byte, msgKey string) @@ -38,7 +39,7 @@ func (mc *HistoryConsumerHandler) Init() { } func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) { - time := utils.GetCurrentTimestampByNano() + now := time.Now() msgFromMQ := pbMsg.MsgDataToMQ{} err := proto.Unmarshal(msg, &msgFromMQ) if err != nil { @@ -62,13 +63,13 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) return } mc.singleMsgCount++ - log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time) + log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now)) } if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID { } else { go sendMessageToPush(&msgFromMQ, msgKey) } - log.NewDebug(operationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time) + log.NewDebug(operationID, "saveUserChat cost time ", time.Since(now)) case constant.GroupChatType: log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = GroupChatType", isHistory, isPersist) if isHistory { @@ -89,13 +90,13 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) return } mc.singleMsgCount++ - log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time) + log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now)) } if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID { } else { go sendMessageToPush(&msgFromMQ, msgKey) } - log.NewDebug(operationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time) + log.NewDebug(operationID, "saveUserChat cost time ", time.Since(now)) default: log.NewError(msgFromMQ.OperationID, "SessionType error", msgFromMQ.String()) return diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 607d36db0..27682ba5b 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -37,7 +37,7 @@ type AtContent struct { func MsgToUser(pushMsg *pbPush.PushMsgReq) { var wsResult []*pbRelay.SingleMsgToUser isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush) - log.Debug("Get msg from msg_transfer And push msg", pushMsg.OperationID, "PushData", pushMsg.String()) + log.Debug(pushMsg.OperationID, "Get msg from msg_transfer And push msg", pushMsg.String()) grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName) //Online push message log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String()) @@ -45,14 +45,14 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) { msgClient := pbRelay.NewOnlineMessageRelayServiceClient(v) reply, err := msgClient.OnlinePushMsg(context.Background(), &pbRelay.OnlinePushMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserID: pushMsg.PushToUserID}) if err != nil { - log.InfoByKv("push data to client rpc err", pushMsg.OperationID, "err", err) + log.NewError("push data to client rpc err", pushMsg.OperationID, "err", err) continue } if reply != nil && reply.Resp != nil { wsResult = append(wsResult, reply.Resp...) } } - log.InfoByKv("push_result", pushMsg.OperationID, "result", wsResult, "sendData", pushMsg.MsgData) + log.NewInfo(pushMsg.OperationID, "push_result", wsResult, "sendData", pushMsg.MsgData) count++ if isOfflinePush && pushMsg.PushToUserID != pushMsg.MsgData.SendID { for _, v := range wsResult { diff --git a/internal/rpc/cache/cache.go b/internal/rpc/cache/cache.go index 8aabca616..7f0c720f6 100644 --- a/internal/rpc/cache/cache.go +++ b/internal/rpc/cache/cache.go @@ -4,6 +4,7 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db" + imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" pbCache "Open_IM/pkg/proto/cache" @@ -46,6 +47,14 @@ func (s *cacheServer) Run() { log.NewInfo("0", "listen network success, ", registerAddress, listener) defer listener.Close() //grpc server + + //to cache + err = SyncDB2Cache() + if err != nil { + log.NewError("", err.Error(), "db to cache failed") + panic(err.Error()) + } + srv := grpc.NewServer() defer srv.GracefulStop() pbCache.RegisterCacheServer(srv, s) @@ -62,14 +71,84 @@ func (s *cacheServer) Run() { log.NewInfo("0", "message cms rpc success") } -func (s *cacheServer) GetUserInfo(_ context.Context, req *pbCache.GetUserInfoReq) (resp *pbCache.GetUserInfoResp, err error) { +func SyncDB2Cache() error { + var err error + log.NewInfo("0", utils.GetSelfFuncName()) + userList, err := imdb.GetAllUser() + if err != nil { + return utils.Wrap(err, "") + } + //err = updateAllUserToCache(userList) + err = updateAllFriendToCache(userList) + err = updateAllBlackListToCache(userList) + return err +} + +func updateAllUserToCache(userList []db.User) error { + for _, userInfo := range userList { + userInfoPb := &commonPb.UserInfo{ + UserID: userInfo.UserID, + Nickname: userInfo.Nickname, + FaceURL: userInfo.FaceURL, + Gender: userInfo.Gender, + PhoneNumber: userInfo.PhoneNumber, + Birth: uint32(userInfo.Birth.Unix()), + Email: userInfo.Email, + Ex: userInfo.Ex, + CreateTime: uint32(userInfo.CreateTime.Unix()), + AppMangerLevel: userInfo.AppMangerLevel, + } + m, err := utils.Pb2Map(userInfoPb) + if err != nil { + log.NewError("", utils.GetSelfFuncName(), err.Error()) + } + if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil { + log.NewError("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error()) + } + } + log.NewInfo("0", utils.GetSelfFuncName(), "ok") + return nil +} + +func updateAllFriendToCache(userList []db.User) error { + log.NewInfo("0", utils.GetSelfFuncName()) + for _, user := range userList { + friendIDList, err := imdb.GetFriendIDListByUserID(user.UserID) + if err != nil { + log.NewError("0", utils.GetSelfFuncName(), err.Error()) + continue + } + if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil { + log.NewError("0", utils.GetSelfFuncName(), err.Error()) + } + } + log.NewInfo("0", utils.GetSelfFuncName(), "ok") + return nil +} + +func updateAllBlackListToCache(userList []db.User) error { + log.NewInfo("0", utils.GetSelfFuncName()) + for _, user := range userList { + blackIDList, err := imdb.GetBlackIDListByUserID(user.UserID) + if err != nil { + log.NewError("", utils.GetSelfFuncName(), err.Error()) + continue + } + if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil { + log.NewError("0", utils.GetSelfFuncName(), err.Error()) + } + } + log.NewInfo("0", utils.GetSelfFuncName(), "ok") + return nil +} + +func (s *cacheServer) GetUserInfoFromCache(_ context.Context, req *pbCache.GetUserInfoFromCacheReq) (resp *pbCache.GetUserInfoFromCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) - resp = &pbCache.GetUserInfoResp{ - UserInfoList: []*commonPb.UserInfo{}, - CommonResp: &pbCache.CommonResp{}, + resp = &pbCache.GetUserInfoFromCacheResp{ + CommonResp: &pbCache.CommonResp{}, } for _, userID := range req.UserIDList { - userInfo, err := db.DB.GetUserInfo(userID) + userInfo, err := db.DB.GetUserInfoFromCache(userID) if err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "get userInfo from cache failed", err.Error()) continue @@ -80,39 +159,104 @@ func (s *cacheServer) GetUserInfo(_ context.Context, req *pbCache.GetUserInfoReq return resp, nil } -func (s *cacheServer) UpdateUserInfo(_ context.Context, req *pbCache.UpdateUserInfoReq) (resp *pbCache.UpdateUserInfoResp, err error) { +func (s *cacheServer) UpdateUserInfoToCache(_ context.Context, req *pbCache.UpdateUserInfoToCacheReq) (resp *pbCache.UpdateUserInfoToCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) - resp = &pbCache.UpdateUserInfoResp{ + resp = &pbCache.UpdateUserInfoToCacheResp{ CommonResp: &pbCache.CommonResp{}, } for _, userInfo := range req.UserInfoList { - if err := db.DB.SetUserInfo(userInfo); err != nil { + m, err := utils.Pb2Map(userInfo) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), *userInfo) + } + if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error()) - return resp, nil } } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil } -func (s *cacheServer) GetBlackList(_ context.Context, req *pbCache.GetBlackListReq) (resp *pbCache.GetBlackListResp, err error) { +func (s *cacheServer) GetFriendIDListFromCache(_ context.Context, req *pbCache.GetFriendIDListFromCacheReq) (resp *pbCache.GetFriendIDListFromCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbCache.GetFriendIDListFromCacheResp{CommonResp: &pbCache.CommonResp{}} + friendIDList, err := db.DB.GetFriendIDListFromCache(req.UserID) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error()) + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + return resp, nil + } + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), friendIDList) + resp.UserIDList = friendIDList + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil +} +func (s *cacheServer) AddFriendToCache(_ context.Context, req *pbCache.AddFriendToCacheReq) (resp *pbCache.AddFriendToCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) - return nil, nil + resp = &pbCache.AddFriendToCacheResp{CommonResp: &pbCache.CommonResp{}} + if err := db.DB.AddFriendToCache(req.UserID, req.FriendID); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error()) + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil } -func (s *cacheServer) UpdateBlackList(_ context.Context, req *pbCache.UpdateBlackListReq) (resp *pbCache.UpdateBlackListResp, err error) { +func (s *cacheServer) ReduceFriendFromCache(_ context.Context, req *pbCache.ReduceFriendFromCacheReq) (resp *pbCache.ReduceFriendFromCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbCache.ReduceFriendFromCacheResp{CommonResp: &pbCache.CommonResp{}} + if err := db.DB.ReduceFriendToCache(req.UserID, req.FriendID); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error()) + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil +} +func (s *cacheServer) GetBlackIDListFromCache(_ context.Context, req *pbCache.GetBlackIDListFromCacheReq) (resp *pbCache.GetBlackIDListFromCacheResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) - return nil, nil + resp = &pbCache.GetBlackIDListFromCacheResp{CommonResp: &pbCache.CommonResp{}} + blackUserIDList, err := db.DB.GetBlackListFromCache(req.UserID) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error()) + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + return resp, nil + } + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), blackUserIDList) + resp.UserIDList = blackUserIDList + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil } -func (s *cacheServer) GetFriendInfo(_ context.Context, req *pbCache.GetFriendInfoReq) (resp *pbCache.GetFriendInfoResp, err error) { - return nil, nil +func (s *cacheServer) AddBlackUserToCache(_ context.Context, req *pbCache.AddBlackUserToCacheReq) (resp *pbCache.AddBlackUserToCacheResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbCache.AddBlackUserToCacheResp{CommonResp: &pbCache.CommonResp{}} + if err := db.DB.AddBlackUserToCache(req.UserID, req.BlackUserID); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil } -func (s *cacheServer) UpdateFriendInfo(_ context.Context, req *pbCache.UpdateFriendInfoReq) (resp *pbCache.UpdateFriendInfoResp, err error) { - return nil, nil +func (s *cacheServer) ReduceBlackUserFromCache(_ context.Context, req *pbCache.ReduceBlackUserFromCacheReq) (resp *pbCache.ReduceBlackUserFromCacheResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbCache.ReduceBlackUserFromCacheResp{CommonResp: &pbCache.CommonResp{}} + if err := db.DB.ReduceBlackUserFromCache(req.UserID, req.BlackUserID); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil } diff --git a/internal/rpc/friend/firend.go b/internal/rpc/friend/firend.go index b570b8106..1fcc7d87f 100644 --- a/internal/rpc/friend/firend.go +++ b/internal/rpc/friend/firend.go @@ -10,6 +10,7 @@ import ( "Open_IM/pkg/common/token_verify" cp "Open_IM/pkg/common/utils" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbCache "Open_IM/pkg/proto/cache" pbFriend "Open_IM/pkg/proto/friend" sdkws "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" @@ -83,6 +84,18 @@ func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlackl return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } log.NewInfo(req.CommID.OperationID, "AddBlacklist rpc ok ", req.CommID.FromUserID, req.CommID.ToUserID) + reqAddBlackUserToCache := &pbCache.AddBlackUserToCacheReq{UserID: req.CommID.FromUserID, BlackUserID: req.CommID.ToUserID, OperationID: req.CommID.OperationID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddBlackUserToCache(context.Background(), reqAddBlackUserToCache) + if err != nil { + log.NewError(req.CommID.OperationID, "AddBlackUserToCache rpc call failed ", err.Error()) + return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: 500, ErrMsg: "AddBlackUserToCache rpc call failed"}}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.CommID.OperationID, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}, nil + } chat.BlackAddedNotification(req) return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{}}, nil } @@ -244,6 +257,24 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF } else { log.Error(req.CommID.OperationID, "HandleResult failed ", req.HandleResult) } + + addFriendToCacheReq := &pbCache.AddFriendToCacheReq{OperationID: req.CommID.OperationID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + client := pbCache.NewCacheClient(etcdConn) + addFriendToCacheReq.UserID = req.CommID.ToUserID + addFriendToCacheReq.UserID = req.CommID.FromUserID + respPb, err := client.AddFriendToCache(context.Background(), addFriendToCacheReq) + addFriendToCacheReq.UserID = req.CommID.FromUserID + addFriendToCacheReq.UserID = req.CommID.ToUserID + respPb, err = client.AddFriendToCache(context.Background(), addFriendToCacheReq) + if err != nil { + log.NewError(req.CommID.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error()) + return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: constant.ErrServer.ErrMsg}}, nil + } + if respPb.CommonResp.ErrCode != 0 { + log.NewError(req.CommID.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed") + return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: respPb.CommonResp.ErrCode, ErrMsg: respPb.CommonResp.ErrMsg}}, nil + } log.NewInfo(req.CommID.OperationID, "rpc AddFriendResponse ok") return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{}}, nil } @@ -262,6 +293,19 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri } log.NewInfo(req.CommID.OperationID, "DeleteFriend rpc ok") chat.FriendDeletedNotification(req) + + reduceFriendFromCache := &pbCache.ReduceFriendFromCacheReq{OperationID: req.CommID.OperationID, UserID: req.CommID.FromUserID, FriendID: req.CommID.ToUserID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + client := pbCache.NewCacheClient(etcdConn) + respPb, err := client.ReduceFriendFromCache(context.Background(), reduceFriendFromCache) + if err != nil { + log.NewError(req.CommID.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error()) + return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: constant.ErrServer.ErrMsg}}, nil + } + if respPb.CommonResp.ErrCode != 0 { + log.NewError(req.CommID.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed") + return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: respPb.CommonResp.ErrCode, ErrMsg: respPb.CommonResp.ErrMsg}}, nil + } return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{}}, nil } @@ -330,6 +374,18 @@ func (s *friendServer) RemoveBlacklist(ctx context.Context, req *pbFriend.Remove } log.NewInfo(req.CommID.OperationID, "rpc RemoveBlacklist ok ") + reqReduceBlackUserFromCache := &pbCache.ReduceBlackUserFromCacheReq{UserID: req.CommID.FromUserID, BlackUserID: req.CommID.ToUserID, OperationID: req.CommID.OperationID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.ReduceBlackUserFromCache(context.Background(), reqReduceBlackUserFromCache) + if err != nil { + log.NewError(req.CommID.OperationID, "ReduceBlackUserFromCache rpc call failed ", err.Error()) + return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: 500, ErrMsg: "ReduceBlackUserFromCache rpc call failed"}}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.CommID.OperationID, "ReduceBlackUserFromCache rpc logic call failed ", cacheResp.String()) + return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}, nil + } chat.BlackDeletedNotification(req) return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{}}, nil } diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index f87278dc5..b80853436 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -6,9 +6,9 @@ import ( "Open_IM/pkg/common/db" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" + cacheRpc "Open_IM/pkg/proto/cache" pbChat "Open_IM/pkg/proto/chat" pbConversation "Open_IM/pkg/proto/conversation" - rpc "Open_IM/pkg/proto/friend" pbGroup "Open_IM/pkg/proto/group" sdk_ws "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" @@ -48,36 +48,38 @@ func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string) return true, 0, "" } log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify) - req := &rpc.IsInBlackListReq{CommID: &rpc.CommID{}} - req.CommID.OperationID = data.OperationID - req.CommID.OpUserID = data.MsgData.RecvID - req.CommID.FromUserID = data.MsgData.RecvID - req.CommID.ToUserID = data.MsgData.SendID - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName) - client := rpc.NewFriendClient(etcdConn) - reply, err := client.IsInBlackList(context.Background(), req) + reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := cacheRpc.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.GetBlackIDListFromCache(context.Background(), reqGetBlackIDListFromCache) if err != nil { - log.NewDebug(data.OperationID, "IsInBlackListReq rpc failed, ", req.String(), err.Error()) - } else if reply.Response == true { - log.NewDebug(data.OperationID, "IsInBlackListReq ", req.String()) - return false, 600, "in black list" + log.NewError(data.OperationID, "GetBlackIDListFromCache rpc call failed ", err.Error()) + } else { + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(data.OperationID, "GetBlackIDListFromCache rpc logic call failed ", cacheResp.String()) + } else { + if utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) { + return false, 600, "in black list" + } + } } log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify) if config.Config.MessageVerify.FriendVerify { - friendReq := &rpc.IsFriendReq{CommID: &rpc.CommID{}} - friendReq.CommID.OperationID = data.OperationID - friendReq.CommID.OpUserID = data.MsgData.RecvID - friendReq.CommID.FromUserID = data.MsgData.RecvID - friendReq.CommID.ToUserID = data.MsgData.SendID - friendReply, err := client.IsFriend(context.Background(), friendReq) + reqGetFriendIDListFromCache := &cacheRpc.GetFriendIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := cacheRpc.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.GetFriendIDListFromCache(context.Background(), reqGetFriendIDListFromCache) if err != nil { - log.NewDebug(data.OperationID, "IsFriendReq rpc failed, ", req.String(), err.Error()) - return true, 0, "" - } else if friendReply.Response == false { - log.NewDebug(data.OperationID, "not friend ", req.String()) - return friendReply.Response, 601, "not friend" + log.NewError(data.OperationID, "GetFriendIDListFromCache rpc call failed ", err.Error()) + } else { + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(data.OperationID, "GetFriendIDListFromCache rpc logic call failed ", cacheResp.String()) + } else { + if !utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) { + return false, 601, "not friend" + } + } } - log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify, friendReply.Response) return true, 0, "" } else { return true, 0, "" diff --git a/pkg/base_info/user_api_struct.go b/pkg/base_info/user_api_struct.go index 10f20376c..b517f24de 100644 --- a/pkg/base_info/user_api_struct.go +++ b/pkg/base_info/user_api_struct.go @@ -32,3 +32,21 @@ type GetSelfUserInfoResp struct { UserInfo *open_im_sdk.UserInfo `json:"-"` Data map[string]interface{} `json:"data"` } + +type GetFriendIDListFromCacheReq struct { + OperationID string `json:"operationID" binding:"required"` +} + +type GetFriendIDListFromCacheResp struct { + CommResp + UserIDList []string `json:"userIDList" binding:"required"` +} + +type GetBlackIDListFromCacheReq struct { + OperationID string `json:"operationID" binding:"required"` +} + +type GetBlackIDListFromCacheResp struct { + CommResp + UserIDList []string `json:"userIDList" binding:"required"` +} diff --git a/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go b/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go index 7a60287a6..3cdbdea96 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go @@ -56,3 +56,16 @@ func GetBlackListByUserID(ownerUserID string) ([]db.Black, error) { } return blackListUsersInfo, nil } + +func GetBlackIDListByUserID(ownerUserID string) ([]string, error) { + dbConn, err := db.DB.MysqlDB.DefaultGormDB() + if err != nil { + return nil, err + } + var blackIDList []string + err = dbConn.Table("blacks").Where("owner_user_id=?", ownerUserID).Pluck("block_user_id", &blackIDList).Error + if err != nil { + return nil, err + } + return blackIDList, nil +} diff --git a/pkg/common/db/mysql_model/im_mysql_model/user_model.go b/pkg/common/db/mysql_model/im_mysql_model/user_model.go index c519ec2d0..4f26cecbe 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/user_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/user_model.go @@ -60,6 +60,16 @@ func DeleteUser(userID string) (i int64) { return i } +func GetAllUser() ([]db.User, error) { + dbConn, err := db.DB.MysqlDB.DefaultGormDB() + if err != nil { + return nil, err + } + var userList []db.User + err = dbConn.Table("users").Find(&userList).Error + return userList, err +} + func GetUserByUserID(userID string) (*db.User, error) { dbConn, err := db.DB.MysqlDB.DefaultGormDB() if err != nil { diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index 9b32b18d7..0241faa9f 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -9,15 +9,17 @@ import ( ) const ( - AccountTempCode = "ACCOUNT_TEMP_CODE" + accountTempCode = "ACCOUNT_TEMP_CODE" resetPwdTempCode = "RESET_PWD_TEMP_CODE" userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq appleDeviceToken = "DEVICE_TOKEN" userMinSeq = "REDIS_USER_MIN_SEQ:" uidPidToken = "UID_PID_TOKEN_STATUS:" conversationReceiveMessageOpt = "CON_RECV_MSG_OPT:" - GetuiToken = "GETUI" - UserInfoCache = "USER_INFO_CACHE:" + getuiToken = "GETUI" + userInfoCache = "USER_INFO_CACHE:" + friendRelationCache = "FRIEND_RELATION_CACHE:" + blackListCache = "BLACK_LIST_CACHE:" ) func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) { @@ -40,16 +42,16 @@ func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (inte return con.Do(cmd, params...) } func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) { - key := AccountTempCode + account + key := accountTempCode + account return redis.Bool(d.Exec("EXISTS", key)) } func (d *DataBases) SetAccountCode(account string, code, ttl int) (err error) { - key := AccountTempCode + account + key := accountTempCode + account _, err = d.Exec("SET", key, code, "ex", ttl) return err } func (d *DataBases) GetAccountCode(account string) (string, error) { - key := AccountTempCode + account + key := accountTempCode + account return redis.String(d.Exec("GET", key)) } @@ -150,27 +152,27 @@ func (d *DataBases) GetMultiConversationMsgOpt(userID string, conversationIDs [] } func (d *DataBases) SetGetuiToken(token string, expireTime int64) error { - _, err := d.Exec("SET", GetuiToken, token, "ex", expireTime) + _, err := d.Exec("SET", getuiToken, token, "ex", expireTime) return err } func (d *DataBases) GetGetuiToken() (string, error) { - result, err := redis.String(d.Exec("GET", GetuiToken)) + result, err := redis.String(d.Exec("GET", getuiToken)) return result, err } -func (d *DataBases) SetUserInfo(userInfo *pbCommon.UserInfo) error { - b, _ := json.Marshal(&userInfo) - m := map[string]interface{}{} - if err := json.Unmarshal(b, &m); err != nil { - return err - } - _, err := d.Exec("hmset", UserInfoCache+userInfo.UserID, redis.Args{}.Add().AddFlat(m)...) +func (d *DataBases) SearchContentType() { + +} + +func (d *DataBases) SetUserInfoToCache(userID string, m map[string]interface{}) error { + _, err := d.Exec("hmset", userInfoCache+userID, redis.Args{}.Add().AddFlat(m)...) return err } -func (d *DataBases) GetUserInfo(userID string) (*pbCommon.UserInfo, error) { - result, err := redis.String(d.Exec("HGETALL", UserInfoCache+userID)) +func (d *DataBases) GetUserInfoFromCache(userID string) (*pbCommon.UserInfo, error) { + result, err := redis.String(d.Exec("hgetall", userInfoCache+userID)) + log2.NewInfo("", result) if err != nil { return nil, err } @@ -178,3 +180,49 @@ func (d *DataBases) GetUserInfo(userID string) (*pbCommon.UserInfo, error) { err = json.Unmarshal([]byte(result), userInfo) return userInfo, err } + +func (d *DataBases) AddFriendToCache(userID string, friendIDList ...string) error { + var IDList []interface{} + for _, id := range friendIDList { + IDList = append(IDList, id) + } + _, err := d.Exec("SADD", friendRelationCache+userID, IDList...) + return err +} + +func (d *DataBases) ReduceFriendToCache(userID string, friendIDList ...string) error { + var IDList []interface{} + for _, id := range friendIDList { + IDList = append(IDList, id) + } + _, err := d.Exec("SREM", friendRelationCache+userID, IDList...) + return err +} + +func (d *DataBases) GetFriendIDListFromCache(userID string) ([]string, error) { + result, err := redis.Strings(d.Exec("SMEMBERS", friendRelationCache+userID)) + return result, err +} + +func (d *DataBases) AddBlackUserToCache(userID string, blackList ...string) error { + var IDList []interface{} + for _, id := range blackList { + IDList = append(IDList, id) + } + _, err := d.Exec("SADD", blackListCache+userID, IDList...) + return err +} + +func (d *DataBases) ReduceBlackUserFromCache(userID string, blackList ...string) error { + var IDList []interface{} + for _, id := range blackList { + IDList = append(IDList, id) + } + _, err := d.Exec("SREM", blackListCache+userID, IDList...) + return err +} + +func (d *DataBases) GetBlackListFromCache(userID string) ([]string, error) { + result, err := redis.Strings(d.Exec("SMEMBERS", blackListCache+userID)) + return result, err +} diff --git a/pkg/common/utils/utils.go b/pkg/common/utils/utils.go index 003f659a9..cf7019492 100644 --- a/pkg/common/utils/utils.go +++ b/pkg/common/utils/utils.go @@ -154,8 +154,3 @@ func UserDBCopyOpenIM(dst *open_im_sdk.UserInfo, src *db.User) { func UserDBCopyOpenIMPublicUser(dst *open_im_sdk.PublicUserInfo, src *db.User) { utils.CopyStructFields(dst, src) } - -// -//func PublicUserDBCopyOpenIM(dst *open_im_sdk.PublicUserInfo, src *db.User){ -// -//} diff --git a/pkg/proto/cache/cache.pb.go b/pkg/proto/cache/cache.pb.go index 430ec0c78..4d4606950 100644 --- a/pkg/proto/cache/cache.pb.go +++ b/pkg/proto/cache/cache.pb.go @@ -36,7 +36,7 @@ func (m *CommonResp) Reset() { *m = CommonResp{} } func (m *CommonResp) String() string { return proto.CompactTextString(m) } func (*CommonResp) ProtoMessage() {} func (*CommonResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{0} + return fileDescriptor_cache_d0822f7e413e82c3, []int{0} } func (m *CommonResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CommonResp.Unmarshal(m, b) @@ -70,53 +70,53 @@ func (m *CommonResp) GetErrMsg() string { return "" } -type GetUserInfoReq struct { +type GetUserInfoFromCacheReq struct { UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"` - OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *GetUserInfoReq) Reset() { *m = GetUserInfoReq{} } -func (m *GetUserInfoReq) String() string { return proto.CompactTextString(m) } -func (*GetUserInfoReq) ProtoMessage() {} -func (*GetUserInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{1} +func (m *GetUserInfoFromCacheReq) Reset() { *m = GetUserInfoFromCacheReq{} } +func (m *GetUserInfoFromCacheReq) String() string { return proto.CompactTextString(m) } +func (*GetUserInfoFromCacheReq) ProtoMessage() {} +func (*GetUserInfoFromCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{1} } -func (m *GetUserInfoReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUserInfoReq.Unmarshal(m, b) +func (m *GetUserInfoFromCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetUserInfoFromCacheReq.Unmarshal(m, b) } -func (m *GetUserInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUserInfoReq.Marshal(b, m, deterministic) +func (m *GetUserInfoFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetUserInfoFromCacheReq.Marshal(b, m, deterministic) } -func (dst *GetUserInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUserInfoReq.Merge(dst, src) +func (dst *GetUserInfoFromCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetUserInfoFromCacheReq.Merge(dst, src) } -func (m *GetUserInfoReq) XXX_Size() int { - return xxx_messageInfo_GetUserInfoReq.Size(m) +func (m *GetUserInfoFromCacheReq) XXX_Size() int { + return xxx_messageInfo_GetUserInfoFromCacheReq.Size(m) } -func (m *GetUserInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetUserInfoReq.DiscardUnknown(m) +func (m *GetUserInfoFromCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetUserInfoFromCacheReq.DiscardUnknown(m) } -var xxx_messageInfo_GetUserInfoReq proto.InternalMessageInfo +var xxx_messageInfo_GetUserInfoFromCacheReq proto.InternalMessageInfo -func (m *GetUserInfoReq) GetUserIDList() []string { +func (m *GetUserInfoFromCacheReq) GetUserIDList() []string { if m != nil { return m.UserIDList } return nil } -func (m *GetUserInfoReq) GetOperationID() string { +func (m *GetUserInfoFromCacheReq) GetOperationID() string { if m != nil { return m.OperationID } return "" } -type GetUserInfoResp struct { +type GetUserInfoFromCacheResp struct { CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` UserInfoList []*sdk_ws.UserInfo `protobuf:"bytes,2,rep,name=userInfoList" json:"userInfoList,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -124,45 +124,45 @@ type GetUserInfoResp struct { XXX_sizecache int32 `json:"-"` } -func (m *GetUserInfoResp) Reset() { *m = GetUserInfoResp{} } -func (m *GetUserInfoResp) String() string { return proto.CompactTextString(m) } -func (*GetUserInfoResp) ProtoMessage() {} -func (*GetUserInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{2} +func (m *GetUserInfoFromCacheResp) Reset() { *m = GetUserInfoFromCacheResp{} } +func (m *GetUserInfoFromCacheResp) String() string { return proto.CompactTextString(m) } +func (*GetUserInfoFromCacheResp) ProtoMessage() {} +func (*GetUserInfoFromCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{2} } -func (m *GetUserInfoResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUserInfoResp.Unmarshal(m, b) +func (m *GetUserInfoFromCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetUserInfoFromCacheResp.Unmarshal(m, b) } -func (m *GetUserInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUserInfoResp.Marshal(b, m, deterministic) +func (m *GetUserInfoFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetUserInfoFromCacheResp.Marshal(b, m, deterministic) } -func (dst *GetUserInfoResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUserInfoResp.Merge(dst, src) +func (dst *GetUserInfoFromCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetUserInfoFromCacheResp.Merge(dst, src) } -func (m *GetUserInfoResp) XXX_Size() int { - return xxx_messageInfo_GetUserInfoResp.Size(m) +func (m *GetUserInfoFromCacheResp) XXX_Size() int { + return xxx_messageInfo_GetUserInfoFromCacheResp.Size(m) } -func (m *GetUserInfoResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetUserInfoResp.DiscardUnknown(m) +func (m *GetUserInfoFromCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetUserInfoFromCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_GetUserInfoResp proto.InternalMessageInfo +var xxx_messageInfo_GetUserInfoFromCacheResp proto.InternalMessageInfo -func (m *GetUserInfoResp) GetCommonResp() *CommonResp { +func (m *GetUserInfoFromCacheResp) GetCommonResp() *CommonResp { if m != nil { return m.CommonResp } return nil } -func (m *GetUserInfoResp) GetUserInfoList() []*sdk_ws.UserInfo { +func (m *GetUserInfoFromCacheResp) GetUserInfoList() []*sdk_ws.UserInfo { if m != nil { return m.UserInfoList } return nil } -type UpdateUserInfoReq struct { +type UpdateUserInfoToCacheReq struct { UserInfoList []*sdk_ws.UserInfo `protobuf:"bytes,1,rep,name=userInfoList" json:"userInfoList,omitempty"` OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -170,83 +170,83 @@ type UpdateUserInfoReq struct { XXX_sizecache int32 `json:"-"` } -func (m *UpdateUserInfoReq) Reset() { *m = UpdateUserInfoReq{} } -func (m *UpdateUserInfoReq) String() string { return proto.CompactTextString(m) } -func (*UpdateUserInfoReq) ProtoMessage() {} -func (*UpdateUserInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{3} +func (m *UpdateUserInfoToCacheReq) Reset() { *m = UpdateUserInfoToCacheReq{} } +func (m *UpdateUserInfoToCacheReq) String() string { return proto.CompactTextString(m) } +func (*UpdateUserInfoToCacheReq) ProtoMessage() {} +func (*UpdateUserInfoToCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{3} } -func (m *UpdateUserInfoReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateUserInfoReq.Unmarshal(m, b) +func (m *UpdateUserInfoToCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UpdateUserInfoToCacheReq.Unmarshal(m, b) } -func (m *UpdateUserInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateUserInfoReq.Marshal(b, m, deterministic) +func (m *UpdateUserInfoToCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UpdateUserInfoToCacheReq.Marshal(b, m, deterministic) } -func (dst *UpdateUserInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateUserInfoReq.Merge(dst, src) +func (dst *UpdateUserInfoToCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateUserInfoToCacheReq.Merge(dst, src) } -func (m *UpdateUserInfoReq) XXX_Size() int { - return xxx_messageInfo_UpdateUserInfoReq.Size(m) +func (m *UpdateUserInfoToCacheReq) XXX_Size() int { + return xxx_messageInfo_UpdateUserInfoToCacheReq.Size(m) } -func (m *UpdateUserInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateUserInfoReq.DiscardUnknown(m) +func (m *UpdateUserInfoToCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateUserInfoToCacheReq.DiscardUnknown(m) } -var xxx_messageInfo_UpdateUserInfoReq proto.InternalMessageInfo +var xxx_messageInfo_UpdateUserInfoToCacheReq proto.InternalMessageInfo -func (m *UpdateUserInfoReq) GetUserInfoList() []*sdk_ws.UserInfo { +func (m *UpdateUserInfoToCacheReq) GetUserInfoList() []*sdk_ws.UserInfo { if m != nil { return m.UserInfoList } return nil } -func (m *UpdateUserInfoReq) GetOperationID() string { +func (m *UpdateUserInfoToCacheReq) GetOperationID() string { if m != nil { return m.OperationID } return "" } -type UpdateUserInfoResp struct { +type UpdateUserInfoToCacheResp struct { CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *UpdateUserInfoResp) Reset() { *m = UpdateUserInfoResp{} } -func (m *UpdateUserInfoResp) String() string { return proto.CompactTextString(m) } -func (*UpdateUserInfoResp) ProtoMessage() {} -func (*UpdateUserInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{4} +func (m *UpdateUserInfoToCacheResp) Reset() { *m = UpdateUserInfoToCacheResp{} } +func (m *UpdateUserInfoToCacheResp) String() string { return proto.CompactTextString(m) } +func (*UpdateUserInfoToCacheResp) ProtoMessage() {} +func (*UpdateUserInfoToCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{4} } -func (m *UpdateUserInfoResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateUserInfoResp.Unmarshal(m, b) +func (m *UpdateUserInfoToCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UpdateUserInfoToCacheResp.Unmarshal(m, b) } -func (m *UpdateUserInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateUserInfoResp.Marshal(b, m, deterministic) +func (m *UpdateUserInfoToCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UpdateUserInfoToCacheResp.Marshal(b, m, deterministic) } -func (dst *UpdateUserInfoResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateUserInfoResp.Merge(dst, src) +func (dst *UpdateUserInfoToCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateUserInfoToCacheResp.Merge(dst, src) } -func (m *UpdateUserInfoResp) XXX_Size() int { - return xxx_messageInfo_UpdateUserInfoResp.Size(m) +func (m *UpdateUserInfoToCacheResp) XXX_Size() int { + return xxx_messageInfo_UpdateUserInfoToCacheResp.Size(m) } -func (m *UpdateUserInfoResp) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateUserInfoResp.DiscardUnknown(m) +func (m *UpdateUserInfoToCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateUserInfoToCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_UpdateUserInfoResp proto.InternalMessageInfo +var xxx_messageInfo_UpdateUserInfoToCacheResp proto.InternalMessageInfo -func (m *UpdateUserInfoResp) GetCommonResp() *CommonResp { +func (m *UpdateUserInfoToCacheResp) GetCommonResp() *CommonResp { if m != nil { return m.CommonResp } return nil } -type GetFriendInfoReq struct { +type GetFriendIDListFromCacheReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -254,175 +254,275 @@ type GetFriendInfoReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetFriendInfoReq) Reset() { *m = GetFriendInfoReq{} } -func (m *GetFriendInfoReq) String() string { return proto.CompactTextString(m) } -func (*GetFriendInfoReq) ProtoMessage() {} -func (*GetFriendInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{5} +func (m *GetFriendIDListFromCacheReq) Reset() { *m = GetFriendIDListFromCacheReq{} } +func (m *GetFriendIDListFromCacheReq) String() string { return proto.CompactTextString(m) } +func (*GetFriendIDListFromCacheReq) ProtoMessage() {} +func (*GetFriendIDListFromCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{5} } -func (m *GetFriendInfoReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFriendInfoReq.Unmarshal(m, b) +func (m *GetFriendIDListFromCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetFriendIDListFromCacheReq.Unmarshal(m, b) } -func (m *GetFriendInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFriendInfoReq.Marshal(b, m, deterministic) +func (m *GetFriendIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetFriendIDListFromCacheReq.Marshal(b, m, deterministic) } -func (dst *GetFriendInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFriendInfoReq.Merge(dst, src) +func (dst *GetFriendIDListFromCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetFriendIDListFromCacheReq.Merge(dst, src) } -func (m *GetFriendInfoReq) XXX_Size() int { - return xxx_messageInfo_GetFriendInfoReq.Size(m) +func (m *GetFriendIDListFromCacheReq) XXX_Size() int { + return xxx_messageInfo_GetFriendIDListFromCacheReq.Size(m) } -func (m *GetFriendInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetFriendInfoReq.DiscardUnknown(m) +func (m *GetFriendIDListFromCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetFriendIDListFromCacheReq.DiscardUnknown(m) } -var xxx_messageInfo_GetFriendInfoReq proto.InternalMessageInfo +var xxx_messageInfo_GetFriendIDListFromCacheReq proto.InternalMessageInfo -func (m *GetFriendInfoReq) GetUserID() string { +func (m *GetFriendIDListFromCacheReq) GetUserID() string { if m != nil { return m.UserID } return "" } -func (m *GetFriendInfoReq) GetOperationID() string { +func (m *GetFriendIDListFromCacheReq) GetOperationID() string { if m != nil { return m.OperationID } return "" } -type GetFriendInfoResp struct { - FriendInfoList []*sdk_ws.FriendInfo `protobuf:"bytes,1,rep,name=friendInfoList" json:"friendInfoList,omitempty"` - CommonResp *CommonResp `protobuf:"bytes,2,opt,name=commonResp" json:"commonResp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type GetFriendIDListFromCacheResp struct { + UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"` + CommonResp *CommonResp `protobuf:"bytes,2,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *GetFriendInfoResp) Reset() { *m = GetFriendInfoResp{} } -func (m *GetFriendInfoResp) String() string { return proto.CompactTextString(m) } -func (*GetFriendInfoResp) ProtoMessage() {} -func (*GetFriendInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{6} +func (m *GetFriendIDListFromCacheResp) Reset() { *m = GetFriendIDListFromCacheResp{} } +func (m *GetFriendIDListFromCacheResp) String() string { return proto.CompactTextString(m) } +func (*GetFriendIDListFromCacheResp) ProtoMessage() {} +func (*GetFriendIDListFromCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{6} } -func (m *GetFriendInfoResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFriendInfoResp.Unmarshal(m, b) +func (m *GetFriendIDListFromCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetFriendIDListFromCacheResp.Unmarshal(m, b) } -func (m *GetFriendInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFriendInfoResp.Marshal(b, m, deterministic) +func (m *GetFriendIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetFriendIDListFromCacheResp.Marshal(b, m, deterministic) } -func (dst *GetFriendInfoResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFriendInfoResp.Merge(dst, src) +func (dst *GetFriendIDListFromCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetFriendIDListFromCacheResp.Merge(dst, src) } -func (m *GetFriendInfoResp) XXX_Size() int { - return xxx_messageInfo_GetFriendInfoResp.Size(m) +func (m *GetFriendIDListFromCacheResp) XXX_Size() int { + return xxx_messageInfo_GetFriendIDListFromCacheResp.Size(m) } -func (m *GetFriendInfoResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetFriendInfoResp.DiscardUnknown(m) +func (m *GetFriendIDListFromCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetFriendIDListFromCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_GetFriendInfoResp proto.InternalMessageInfo +var xxx_messageInfo_GetFriendIDListFromCacheResp proto.InternalMessageInfo -func (m *GetFriendInfoResp) GetFriendInfoList() []*sdk_ws.FriendInfo { +func (m *GetFriendIDListFromCacheResp) GetUserIDList() []string { if m != nil { - return m.FriendInfoList + return m.UserIDList } return nil } -func (m *GetFriendInfoResp) GetCommonResp() *CommonResp { +func (m *GetFriendIDListFromCacheResp) GetCommonResp() *CommonResp { if m != nil { return m.CommonResp } return nil } -type UpdateBlackListReq struct { - BlackList []*sdk_ws.BlackInfo `protobuf:"bytes,1,rep,name=blackList" json:"blackList,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type AddFriendToCacheReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + FriendID string `protobuf:"bytes,2,opt,name=friendID" json:"friendID,omitempty"` + OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AddFriendToCacheReq) Reset() { *m = AddFriendToCacheReq{} } +func (m *AddFriendToCacheReq) String() string { return proto.CompactTextString(m) } +func (*AddFriendToCacheReq) ProtoMessage() {} +func (*AddFriendToCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{7} +} +func (m *AddFriendToCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AddFriendToCacheReq.Unmarshal(m, b) +} +func (m *AddFriendToCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AddFriendToCacheReq.Marshal(b, m, deterministic) +} +func (dst *AddFriendToCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddFriendToCacheReq.Merge(dst, src) +} +func (m *AddFriendToCacheReq) XXX_Size() int { + return xxx_messageInfo_AddFriendToCacheReq.Size(m) +} +func (m *AddFriendToCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_AddFriendToCacheReq.DiscardUnknown(m) +} + +var xxx_messageInfo_AddFriendToCacheReq proto.InternalMessageInfo + +func (m *AddFriendToCacheReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *AddFriendToCacheReq) GetFriendID() string { + if m != nil { + return m.FriendID + } + return "" } -func (m *UpdateBlackListReq) Reset() { *m = UpdateBlackListReq{} } -func (m *UpdateBlackListReq) String() string { return proto.CompactTextString(m) } -func (*UpdateBlackListReq) ProtoMessage() {} -func (*UpdateBlackListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{7} +func (m *AddFriendToCacheReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" } -func (m *UpdateBlackListReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateBlackListReq.Unmarshal(m, b) + +type AddFriendToCacheResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AddFriendToCacheResp) Reset() { *m = AddFriendToCacheResp{} } +func (m *AddFriendToCacheResp) String() string { return proto.CompactTextString(m) } +func (*AddFriendToCacheResp) ProtoMessage() {} +func (*AddFriendToCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{8} } -func (m *UpdateBlackListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateBlackListReq.Marshal(b, m, deterministic) +func (m *AddFriendToCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AddFriendToCacheResp.Unmarshal(m, b) } -func (dst *UpdateBlackListReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateBlackListReq.Merge(dst, src) +func (m *AddFriendToCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AddFriendToCacheResp.Marshal(b, m, deterministic) } -func (m *UpdateBlackListReq) XXX_Size() int { - return xxx_messageInfo_UpdateBlackListReq.Size(m) +func (dst *AddFriendToCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddFriendToCacheResp.Merge(dst, src) } -func (m *UpdateBlackListReq) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateBlackListReq.DiscardUnknown(m) +func (m *AddFriendToCacheResp) XXX_Size() int { + return xxx_messageInfo_AddFriendToCacheResp.Size(m) +} +func (m *AddFriendToCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_AddFriendToCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_UpdateBlackListReq proto.InternalMessageInfo +var xxx_messageInfo_AddFriendToCacheResp proto.InternalMessageInfo -func (m *UpdateBlackListReq) GetBlackList() []*sdk_ws.BlackInfo { +func (m *AddFriendToCacheResp) GetCommonResp() *CommonResp { if m != nil { - return m.BlackList + return m.CommonResp } return nil } -func (m *UpdateBlackListReq) GetOperationID() string { +type ReduceFriendFromCacheReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + FriendID string `protobuf:"bytes,2,opt,name=friendID" json:"friendID,omitempty"` + OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ReduceFriendFromCacheReq) Reset() { *m = ReduceFriendFromCacheReq{} } +func (m *ReduceFriendFromCacheReq) String() string { return proto.CompactTextString(m) } +func (*ReduceFriendFromCacheReq) ProtoMessage() {} +func (*ReduceFriendFromCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{9} +} +func (m *ReduceFriendFromCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ReduceFriendFromCacheReq.Unmarshal(m, b) +} +func (m *ReduceFriendFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ReduceFriendFromCacheReq.Marshal(b, m, deterministic) +} +func (dst *ReduceFriendFromCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReduceFriendFromCacheReq.Merge(dst, src) +} +func (m *ReduceFriendFromCacheReq) XXX_Size() int { + return xxx_messageInfo_ReduceFriendFromCacheReq.Size(m) +} +func (m *ReduceFriendFromCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_ReduceFriendFromCacheReq.DiscardUnknown(m) +} + +var xxx_messageInfo_ReduceFriendFromCacheReq proto.InternalMessageInfo + +func (m *ReduceFriendFromCacheReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *ReduceFriendFromCacheReq) GetFriendID() string { + if m != nil { + return m.FriendID + } + return "" +} + +func (m *ReduceFriendFromCacheReq) GetOperationID() string { if m != nil { return m.OperationID } return "" } -type UpdateBlackListResp struct { +type ReduceFriendFromCacheResp struct { CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *UpdateBlackListResp) Reset() { *m = UpdateBlackListResp{} } -func (m *UpdateBlackListResp) String() string { return proto.CompactTextString(m) } -func (*UpdateBlackListResp) ProtoMessage() {} -func (*UpdateBlackListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{8} +func (m *ReduceFriendFromCacheResp) Reset() { *m = ReduceFriendFromCacheResp{} } +func (m *ReduceFriendFromCacheResp) String() string { return proto.CompactTextString(m) } +func (*ReduceFriendFromCacheResp) ProtoMessage() {} +func (*ReduceFriendFromCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{10} } -func (m *UpdateBlackListResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateBlackListResp.Unmarshal(m, b) +func (m *ReduceFriendFromCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ReduceFriendFromCacheResp.Unmarshal(m, b) } -func (m *UpdateBlackListResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateBlackListResp.Marshal(b, m, deterministic) +func (m *ReduceFriendFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ReduceFriendFromCacheResp.Marshal(b, m, deterministic) } -func (dst *UpdateBlackListResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateBlackListResp.Merge(dst, src) +func (dst *ReduceFriendFromCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReduceFriendFromCacheResp.Merge(dst, src) } -func (m *UpdateBlackListResp) XXX_Size() int { - return xxx_messageInfo_UpdateBlackListResp.Size(m) +func (m *ReduceFriendFromCacheResp) XXX_Size() int { + return xxx_messageInfo_ReduceFriendFromCacheResp.Size(m) } -func (m *UpdateBlackListResp) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateBlackListResp.DiscardUnknown(m) +func (m *ReduceFriendFromCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_ReduceFriendFromCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_UpdateBlackListResp proto.InternalMessageInfo +var xxx_messageInfo_ReduceFriendFromCacheResp proto.InternalMessageInfo -func (m *UpdateBlackListResp) GetCommonResp() *CommonResp { +func (m *ReduceFriendFromCacheResp) GetCommonResp() *CommonResp { if m != nil { return m.CommonResp } return nil } -type GetBlackListReq struct { +type GetBlackIDListFromCacheReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -430,160 +530,268 @@ type GetBlackListReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetBlackListReq) Reset() { *m = GetBlackListReq{} } -func (m *GetBlackListReq) String() string { return proto.CompactTextString(m) } -func (*GetBlackListReq) ProtoMessage() {} -func (*GetBlackListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{9} +func (m *GetBlackIDListFromCacheReq) Reset() { *m = GetBlackIDListFromCacheReq{} } +func (m *GetBlackIDListFromCacheReq) String() string { return proto.CompactTextString(m) } +func (*GetBlackIDListFromCacheReq) ProtoMessage() {} +func (*GetBlackIDListFromCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{11} } -func (m *GetBlackListReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetBlackListReq.Unmarshal(m, b) +func (m *GetBlackIDListFromCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetBlackIDListFromCacheReq.Unmarshal(m, b) } -func (m *GetBlackListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetBlackListReq.Marshal(b, m, deterministic) +func (m *GetBlackIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetBlackIDListFromCacheReq.Marshal(b, m, deterministic) } -func (dst *GetBlackListReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBlackListReq.Merge(dst, src) +func (dst *GetBlackIDListFromCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetBlackIDListFromCacheReq.Merge(dst, src) } -func (m *GetBlackListReq) XXX_Size() int { - return xxx_messageInfo_GetBlackListReq.Size(m) +func (m *GetBlackIDListFromCacheReq) XXX_Size() int { + return xxx_messageInfo_GetBlackIDListFromCacheReq.Size(m) } -func (m *GetBlackListReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetBlackListReq.DiscardUnknown(m) +func (m *GetBlackIDListFromCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetBlackIDListFromCacheReq.DiscardUnknown(m) } -var xxx_messageInfo_GetBlackListReq proto.InternalMessageInfo +var xxx_messageInfo_GetBlackIDListFromCacheReq proto.InternalMessageInfo -func (m *GetBlackListReq) GetUserID() string { +func (m *GetBlackIDListFromCacheReq) GetUserID() string { if m != nil { return m.UserID } return "" } -func (m *GetBlackListReq) GetOperationID() string { +func (m *GetBlackIDListFromCacheReq) GetOperationID() string { if m != nil { return m.OperationID } return "" } -type GetBlackListResp struct { - BlackList []*sdk_ws.BlackInfo `protobuf:"bytes,1,rep,name=blackList" json:"blackList,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type GetBlackIDListFromCacheResp struct { + UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"` + CommonResp *CommonResp `protobuf:"bytes,2,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *GetBlackListResp) Reset() { *m = GetBlackListResp{} } -func (m *GetBlackListResp) String() string { return proto.CompactTextString(m) } -func (*GetBlackListResp) ProtoMessage() {} -func (*GetBlackListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{10} +func (m *GetBlackIDListFromCacheResp) Reset() { *m = GetBlackIDListFromCacheResp{} } +func (m *GetBlackIDListFromCacheResp) String() string { return proto.CompactTextString(m) } +func (*GetBlackIDListFromCacheResp) ProtoMessage() {} +func (*GetBlackIDListFromCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{12} } -func (m *GetBlackListResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetBlackListResp.Unmarshal(m, b) +func (m *GetBlackIDListFromCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetBlackIDListFromCacheResp.Unmarshal(m, b) } -func (m *GetBlackListResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetBlackListResp.Marshal(b, m, deterministic) +func (m *GetBlackIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetBlackIDListFromCacheResp.Marshal(b, m, deterministic) } -func (dst *GetBlackListResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBlackListResp.Merge(dst, src) +func (dst *GetBlackIDListFromCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetBlackIDListFromCacheResp.Merge(dst, src) } -func (m *GetBlackListResp) XXX_Size() int { - return xxx_messageInfo_GetBlackListResp.Size(m) +func (m *GetBlackIDListFromCacheResp) XXX_Size() int { + return xxx_messageInfo_GetBlackIDListFromCacheResp.Size(m) } -func (m *GetBlackListResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetBlackListResp.DiscardUnknown(m) +func (m *GetBlackIDListFromCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetBlackIDListFromCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_GetBlackListResp proto.InternalMessageInfo +var xxx_messageInfo_GetBlackIDListFromCacheResp proto.InternalMessageInfo + +func (m *GetBlackIDListFromCacheResp) GetUserIDList() []string { + if m != nil { + return m.UserIDList + } + return nil +} -func (m *GetBlackListResp) GetBlackList() []*sdk_ws.BlackInfo { +func (m *GetBlackIDListFromCacheResp) GetCommonResp() *CommonResp { if m != nil { - return m.BlackList + return m.CommonResp } return nil } -type UpdateFriendInfoReq struct { - FriendInfoList []*sdk_ws.FriendInfo `protobuf:"bytes,1,rep,name=friendInfoList" json:"friendInfoList,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type AddBlackUserToCacheReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + BlackUserID string `protobuf:"bytes,2,opt,name=blackUserID" json:"blackUserID,omitempty"` + OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AddBlackUserToCacheReq) Reset() { *m = AddBlackUserToCacheReq{} } +func (m *AddBlackUserToCacheReq) String() string { return proto.CompactTextString(m) } +func (*AddBlackUserToCacheReq) ProtoMessage() {} +func (*AddBlackUserToCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{13} +} +func (m *AddBlackUserToCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AddBlackUserToCacheReq.Unmarshal(m, b) +} +func (m *AddBlackUserToCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AddBlackUserToCacheReq.Marshal(b, m, deterministic) +} +func (dst *AddBlackUserToCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddBlackUserToCacheReq.Merge(dst, src) +} +func (m *AddBlackUserToCacheReq) XXX_Size() int { + return xxx_messageInfo_AddBlackUserToCacheReq.Size(m) +} +func (m *AddBlackUserToCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_AddBlackUserToCacheReq.DiscardUnknown(m) +} + +var xxx_messageInfo_AddBlackUserToCacheReq proto.InternalMessageInfo + +func (m *AddBlackUserToCacheReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *AddBlackUserToCacheReq) GetBlackUserID() string { + if m != nil { + return m.BlackUserID + } + return "" +} + +func (m *AddBlackUserToCacheReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type AddBlackUserToCacheResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *UpdateFriendInfoReq) Reset() { *m = UpdateFriendInfoReq{} } -func (m *UpdateFriendInfoReq) String() string { return proto.CompactTextString(m) } -func (*UpdateFriendInfoReq) ProtoMessage() {} -func (*UpdateFriendInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{11} +func (m *AddBlackUserToCacheResp) Reset() { *m = AddBlackUserToCacheResp{} } +func (m *AddBlackUserToCacheResp) String() string { return proto.CompactTextString(m) } +func (*AddBlackUserToCacheResp) ProtoMessage() {} +func (*AddBlackUserToCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{14} } -func (m *UpdateFriendInfoReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateFriendInfoReq.Unmarshal(m, b) +func (m *AddBlackUserToCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AddBlackUserToCacheResp.Unmarshal(m, b) } -func (m *UpdateFriendInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateFriendInfoReq.Marshal(b, m, deterministic) +func (m *AddBlackUserToCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AddBlackUserToCacheResp.Marshal(b, m, deterministic) } -func (dst *UpdateFriendInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateFriendInfoReq.Merge(dst, src) +func (dst *AddBlackUserToCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddBlackUserToCacheResp.Merge(dst, src) } -func (m *UpdateFriendInfoReq) XXX_Size() int { - return xxx_messageInfo_UpdateFriendInfoReq.Size(m) +func (m *AddBlackUserToCacheResp) XXX_Size() int { + return xxx_messageInfo_AddBlackUserToCacheResp.Size(m) } -func (m *UpdateFriendInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateFriendInfoReq.DiscardUnknown(m) +func (m *AddBlackUserToCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_AddBlackUserToCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_UpdateFriendInfoReq proto.InternalMessageInfo +var xxx_messageInfo_AddBlackUserToCacheResp proto.InternalMessageInfo -func (m *UpdateFriendInfoReq) GetFriendInfoList() []*sdk_ws.FriendInfo { +func (m *AddBlackUserToCacheResp) GetCommonResp() *CommonResp { if m != nil { - return m.FriendInfoList + return m.CommonResp } return nil } -func (m *UpdateFriendInfoReq) GetOperationID() string { +type ReduceBlackUserFromCacheReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + BlackUserID string `protobuf:"bytes,2,opt,name=blackUserID" json:"blackUserID,omitempty"` + OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ReduceBlackUserFromCacheReq) Reset() { *m = ReduceBlackUserFromCacheReq{} } +func (m *ReduceBlackUserFromCacheReq) String() string { return proto.CompactTextString(m) } +func (*ReduceBlackUserFromCacheReq) ProtoMessage() {} +func (*ReduceBlackUserFromCacheReq) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{15} +} +func (m *ReduceBlackUserFromCacheReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ReduceBlackUserFromCacheReq.Unmarshal(m, b) +} +func (m *ReduceBlackUserFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ReduceBlackUserFromCacheReq.Marshal(b, m, deterministic) +} +func (dst *ReduceBlackUserFromCacheReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReduceBlackUserFromCacheReq.Merge(dst, src) +} +func (m *ReduceBlackUserFromCacheReq) XXX_Size() int { + return xxx_messageInfo_ReduceBlackUserFromCacheReq.Size(m) +} +func (m *ReduceBlackUserFromCacheReq) XXX_DiscardUnknown() { + xxx_messageInfo_ReduceBlackUserFromCacheReq.DiscardUnknown(m) +} + +var xxx_messageInfo_ReduceBlackUserFromCacheReq proto.InternalMessageInfo + +func (m *ReduceBlackUserFromCacheReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *ReduceBlackUserFromCacheReq) GetBlackUserID() string { + if m != nil { + return m.BlackUserID + } + return "" +} + +func (m *ReduceBlackUserFromCacheReq) GetOperationID() string { if m != nil { return m.OperationID } return "" } -type UpdateFriendInfoResp struct { +type ReduceBlackUserFromCacheResp struct { CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *UpdateFriendInfoResp) Reset() { *m = UpdateFriendInfoResp{} } -func (m *UpdateFriendInfoResp) String() string { return proto.CompactTextString(m) } -func (*UpdateFriendInfoResp) ProtoMessage() {} -func (*UpdateFriendInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_cache_c95b22de9c135769, []int{12} +func (m *ReduceBlackUserFromCacheResp) Reset() { *m = ReduceBlackUserFromCacheResp{} } +func (m *ReduceBlackUserFromCacheResp) String() string { return proto.CompactTextString(m) } +func (*ReduceBlackUserFromCacheResp) ProtoMessage() {} +func (*ReduceBlackUserFromCacheResp) Descriptor() ([]byte, []int) { + return fileDescriptor_cache_d0822f7e413e82c3, []int{16} } -func (m *UpdateFriendInfoResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateFriendInfoResp.Unmarshal(m, b) +func (m *ReduceBlackUserFromCacheResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ReduceBlackUserFromCacheResp.Unmarshal(m, b) } -func (m *UpdateFriendInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateFriendInfoResp.Marshal(b, m, deterministic) +func (m *ReduceBlackUserFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ReduceBlackUserFromCacheResp.Marshal(b, m, deterministic) } -func (dst *UpdateFriendInfoResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateFriendInfoResp.Merge(dst, src) +func (dst *ReduceBlackUserFromCacheResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReduceBlackUserFromCacheResp.Merge(dst, src) } -func (m *UpdateFriendInfoResp) XXX_Size() int { - return xxx_messageInfo_UpdateFriendInfoResp.Size(m) +func (m *ReduceBlackUserFromCacheResp) XXX_Size() int { + return xxx_messageInfo_ReduceBlackUserFromCacheResp.Size(m) } -func (m *UpdateFriendInfoResp) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateFriendInfoResp.DiscardUnknown(m) +func (m *ReduceBlackUserFromCacheResp) XXX_DiscardUnknown() { + xxx_messageInfo_ReduceBlackUserFromCacheResp.DiscardUnknown(m) } -var xxx_messageInfo_UpdateFriendInfoResp proto.InternalMessageInfo +var xxx_messageInfo_ReduceBlackUserFromCacheResp proto.InternalMessageInfo -func (m *UpdateFriendInfoResp) GetCommonResp() *CommonResp { +func (m *ReduceBlackUserFromCacheResp) GetCommonResp() *CommonResp { if m != nil { return m.CommonResp } @@ -592,18 +800,22 @@ func (m *UpdateFriendInfoResp) GetCommonResp() *CommonResp { func init() { proto.RegisterType((*CommonResp)(nil), "cache.CommonResp") - proto.RegisterType((*GetUserInfoReq)(nil), "cache.GetUserInfoReq") - proto.RegisterType((*GetUserInfoResp)(nil), "cache.GetUserInfoResp") - proto.RegisterType((*UpdateUserInfoReq)(nil), "cache.UpdateUserInfoReq") - proto.RegisterType((*UpdateUserInfoResp)(nil), "cache.UpdateUserInfoResp") - proto.RegisterType((*GetFriendInfoReq)(nil), "cache.GetFriendInfoReq") - proto.RegisterType((*GetFriendInfoResp)(nil), "cache.GetFriendInfoResp") - proto.RegisterType((*UpdateBlackListReq)(nil), "cache.UpdateBlackListReq") - proto.RegisterType((*UpdateBlackListResp)(nil), "cache.UpdateBlackListResp") - proto.RegisterType((*GetBlackListReq)(nil), "cache.GetBlackListReq") - proto.RegisterType((*GetBlackListResp)(nil), "cache.GetBlackListResp") - proto.RegisterType((*UpdateFriendInfoReq)(nil), "cache.UpdateFriendInfoReq") - proto.RegisterType((*UpdateFriendInfoResp)(nil), "cache.UpdateFriendInfoResp") + proto.RegisterType((*GetUserInfoFromCacheReq)(nil), "cache.GetUserInfoFromCacheReq") + proto.RegisterType((*GetUserInfoFromCacheResp)(nil), "cache.GetUserInfoFromCacheResp") + proto.RegisterType((*UpdateUserInfoToCacheReq)(nil), "cache.UpdateUserInfoToCacheReq") + proto.RegisterType((*UpdateUserInfoToCacheResp)(nil), "cache.UpdateUserInfoToCacheResp") + proto.RegisterType((*GetFriendIDListFromCacheReq)(nil), "cache.GetFriendIDListFromCacheReq") + proto.RegisterType((*GetFriendIDListFromCacheResp)(nil), "cache.GetFriendIDListFromCacheResp") + proto.RegisterType((*AddFriendToCacheReq)(nil), "cache.AddFriendToCacheReq") + proto.RegisterType((*AddFriendToCacheResp)(nil), "cache.AddFriendToCacheResp") + proto.RegisterType((*ReduceFriendFromCacheReq)(nil), "cache.ReduceFriendFromCacheReq") + proto.RegisterType((*ReduceFriendFromCacheResp)(nil), "cache.ReduceFriendFromCacheResp") + proto.RegisterType((*GetBlackIDListFromCacheReq)(nil), "cache.GetBlackIDListFromCacheReq") + proto.RegisterType((*GetBlackIDListFromCacheResp)(nil), "cache.GetBlackIDListFromCacheResp") + proto.RegisterType((*AddBlackUserToCacheReq)(nil), "cache.AddBlackUserToCacheReq") + proto.RegisterType((*AddBlackUserToCacheResp)(nil), "cache.AddBlackUserToCacheResp") + proto.RegisterType((*ReduceBlackUserFromCacheReq)(nil), "cache.ReduceBlackUserFromCacheReq") + proto.RegisterType((*ReduceBlackUserFromCacheResp)(nil), "cache.ReduceBlackUserFromCacheResp") } // Reference imports to suppress errors if they are not otherwise used. @@ -617,12 +829,17 @@ const _ = grpc.SupportPackageIsVersion4 // Client API for Cache service type CacheClient interface { - GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) - UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*UpdateUserInfoResp, error) - GetFriendInfo(ctx context.Context, in *GetFriendInfoReq, opts ...grpc.CallOption) (*GetFriendInfoResp, error) - UpdateFriendInfo(ctx context.Context, in *UpdateFriendInfoReq, opts ...grpc.CallOption) (*UpdateFriendInfoResp, error) - UpdateBlackList(ctx context.Context, in *UpdateBlackListReq, opts ...grpc.CallOption) (*UpdateBlackListResp, error) - GetBlackList(ctx context.Context, in *GetBlackListReq, opts ...grpc.CallOption) (*GetBlackListResp, error) + // userInfo + GetUserInfoFromCache(ctx context.Context, in *GetUserInfoFromCacheReq, opts ...grpc.CallOption) (*GetUserInfoFromCacheResp, error) + UpdateUserInfoToCache(ctx context.Context, in *UpdateUserInfoToCacheReq, opts ...grpc.CallOption) (*UpdateUserInfoToCacheResp, error) + // friendInfo + GetFriendIDListFromCache(ctx context.Context, in *GetFriendIDListFromCacheReq, opts ...grpc.CallOption) (*GetFriendIDListFromCacheResp, error) + AddFriendToCache(ctx context.Context, in *AddFriendToCacheReq, opts ...grpc.CallOption) (*AddFriendToCacheResp, error) + ReduceFriendFromCache(ctx context.Context, in *ReduceFriendFromCacheReq, opts ...grpc.CallOption) (*ReduceFriendFromCacheResp, error) + // blackList + GetBlackIDListFromCache(ctx context.Context, in *GetBlackIDListFromCacheReq, opts ...grpc.CallOption) (*GetBlackIDListFromCacheResp, error) + AddBlackUserToCache(ctx context.Context, in *AddBlackUserToCacheReq, opts ...grpc.CallOption) (*AddBlackUserToCacheResp, error) + ReduceBlackUserFromCache(ctx context.Context, in *ReduceBlackUserFromCacheReq, opts ...grpc.CallOption) (*ReduceBlackUserFromCacheResp, error) } type cacheClient struct { @@ -633,54 +850,72 @@ func NewCacheClient(cc *grpc.ClientConn) CacheClient { return &cacheClient{cc} } -func (c *cacheClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) { - out := new(GetUserInfoResp) - err := grpc.Invoke(ctx, "/cache.cache/GetUserInfo", in, out, c.cc, opts...) +func (c *cacheClient) GetUserInfoFromCache(ctx context.Context, in *GetUserInfoFromCacheReq, opts ...grpc.CallOption) (*GetUserInfoFromCacheResp, error) { + out := new(GetUserInfoFromCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/GetUserInfoFromCache", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *cacheClient) UpdateUserInfoToCache(ctx context.Context, in *UpdateUserInfoToCacheReq, opts ...grpc.CallOption) (*UpdateUserInfoToCacheResp, error) { + out := new(UpdateUserInfoToCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/UpdateUserInfoToCache", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *cacheClient) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*UpdateUserInfoResp, error) { - out := new(UpdateUserInfoResp) - err := grpc.Invoke(ctx, "/cache.cache/UpdateUserInfo", in, out, c.cc, opts...) +func (c *cacheClient) GetFriendIDListFromCache(ctx context.Context, in *GetFriendIDListFromCacheReq, opts ...grpc.CallOption) (*GetFriendIDListFromCacheResp, error) { + out := new(GetFriendIDListFromCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/GetFriendIDListFromCache", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *cacheClient) GetFriendInfo(ctx context.Context, in *GetFriendInfoReq, opts ...grpc.CallOption) (*GetFriendInfoResp, error) { - out := new(GetFriendInfoResp) - err := grpc.Invoke(ctx, "/cache.cache/GetFriendInfo", in, out, c.cc, opts...) +func (c *cacheClient) AddFriendToCache(ctx context.Context, in *AddFriendToCacheReq, opts ...grpc.CallOption) (*AddFriendToCacheResp, error) { + out := new(AddFriendToCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/AddFriendToCache", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *cacheClient) UpdateFriendInfo(ctx context.Context, in *UpdateFriendInfoReq, opts ...grpc.CallOption) (*UpdateFriendInfoResp, error) { - out := new(UpdateFriendInfoResp) - err := grpc.Invoke(ctx, "/cache.cache/UpdateFriendInfo", in, out, c.cc, opts...) +func (c *cacheClient) ReduceFriendFromCache(ctx context.Context, in *ReduceFriendFromCacheReq, opts ...grpc.CallOption) (*ReduceFriendFromCacheResp, error) { + out := new(ReduceFriendFromCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/ReduceFriendFromCache", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *cacheClient) UpdateBlackList(ctx context.Context, in *UpdateBlackListReq, opts ...grpc.CallOption) (*UpdateBlackListResp, error) { - out := new(UpdateBlackListResp) - err := grpc.Invoke(ctx, "/cache.cache/UpdateBlackList", in, out, c.cc, opts...) +func (c *cacheClient) GetBlackIDListFromCache(ctx context.Context, in *GetBlackIDListFromCacheReq, opts ...grpc.CallOption) (*GetBlackIDListFromCacheResp, error) { + out := new(GetBlackIDListFromCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/GetBlackIDListFromCache", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *cacheClient) GetBlackList(ctx context.Context, in *GetBlackListReq, opts ...grpc.CallOption) (*GetBlackListResp, error) { - out := new(GetBlackListResp) - err := grpc.Invoke(ctx, "/cache.cache/GetBlackList", in, out, c.cc, opts...) +func (c *cacheClient) AddBlackUserToCache(ctx context.Context, in *AddBlackUserToCacheReq, opts ...grpc.CallOption) (*AddBlackUserToCacheResp, error) { + out := new(AddBlackUserToCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/AddBlackUserToCache", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *cacheClient) ReduceBlackUserFromCache(ctx context.Context, in *ReduceBlackUserFromCacheReq, opts ...grpc.CallOption) (*ReduceBlackUserFromCacheResp, error) { + out := new(ReduceBlackUserFromCacheResp) + err := grpc.Invoke(ctx, "/cache.cache/ReduceBlackUserFromCache", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -690,122 +925,163 @@ func (c *cacheClient) GetBlackList(ctx context.Context, in *GetBlackListReq, opt // Server API for Cache service type CacheServer interface { - GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) - UpdateUserInfo(context.Context, *UpdateUserInfoReq) (*UpdateUserInfoResp, error) - GetFriendInfo(context.Context, *GetFriendInfoReq) (*GetFriendInfoResp, error) - UpdateFriendInfo(context.Context, *UpdateFriendInfoReq) (*UpdateFriendInfoResp, error) - UpdateBlackList(context.Context, *UpdateBlackListReq) (*UpdateBlackListResp, error) - GetBlackList(context.Context, *GetBlackListReq) (*GetBlackListResp, error) + // userInfo + GetUserInfoFromCache(context.Context, *GetUserInfoFromCacheReq) (*GetUserInfoFromCacheResp, error) + UpdateUserInfoToCache(context.Context, *UpdateUserInfoToCacheReq) (*UpdateUserInfoToCacheResp, error) + // friendInfo + GetFriendIDListFromCache(context.Context, *GetFriendIDListFromCacheReq) (*GetFriendIDListFromCacheResp, error) + AddFriendToCache(context.Context, *AddFriendToCacheReq) (*AddFriendToCacheResp, error) + ReduceFriendFromCache(context.Context, *ReduceFriendFromCacheReq) (*ReduceFriendFromCacheResp, error) + // blackList + GetBlackIDListFromCache(context.Context, *GetBlackIDListFromCacheReq) (*GetBlackIDListFromCacheResp, error) + AddBlackUserToCache(context.Context, *AddBlackUserToCacheReq) (*AddBlackUserToCacheResp, error) + ReduceBlackUserFromCache(context.Context, *ReduceBlackUserFromCacheReq) (*ReduceBlackUserFromCacheResp, error) } func RegisterCacheServer(s *grpc.Server, srv CacheServer) { s.RegisterService(&_Cache_serviceDesc, srv) } -func _Cache_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUserInfoReq) +func _Cache_GetUserInfoFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserInfoFromCacheReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CacheServer).GetUserInfoFromCache(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cache.cache/GetUserInfoFromCache", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CacheServer).GetUserInfoFromCache(ctx, req.(*GetUserInfoFromCacheReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Cache_UpdateUserInfoToCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUserInfoToCacheReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CacheServer).GetUserInfo(ctx, in) + return srv.(CacheServer).UpdateUserInfoToCache(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cache.cache/GetUserInfo", + FullMethod: "/cache.cache/UpdateUserInfoToCache", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CacheServer).GetUserInfo(ctx, req.(*GetUserInfoReq)) + return srv.(CacheServer).UpdateUserInfoToCache(ctx, req.(*UpdateUserInfoToCacheReq)) } return interceptor(ctx, in, info, handler) } -func _Cache_UpdateUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateUserInfoReq) +func _Cache_GetFriendIDListFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetFriendIDListFromCacheReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CacheServer).UpdateUserInfo(ctx, in) + return srv.(CacheServer).GetFriendIDListFromCache(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cache.cache/UpdateUserInfo", + FullMethod: "/cache.cache/GetFriendIDListFromCache", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CacheServer).UpdateUserInfo(ctx, req.(*UpdateUserInfoReq)) + return srv.(CacheServer).GetFriendIDListFromCache(ctx, req.(*GetFriendIDListFromCacheReq)) } return interceptor(ctx, in, info, handler) } -func _Cache_GetFriendInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetFriendInfoReq) +func _Cache_AddFriendToCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddFriendToCacheReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CacheServer).GetFriendInfo(ctx, in) + return srv.(CacheServer).AddFriendToCache(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cache.cache/GetFriendInfo", + FullMethod: "/cache.cache/AddFriendToCache", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CacheServer).GetFriendInfo(ctx, req.(*GetFriendInfoReq)) + return srv.(CacheServer).AddFriendToCache(ctx, req.(*AddFriendToCacheReq)) } return interceptor(ctx, in, info, handler) } -func _Cache_UpdateFriendInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateFriendInfoReq) +func _Cache_ReduceFriendFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReduceFriendFromCacheReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CacheServer).UpdateFriendInfo(ctx, in) + return srv.(CacheServer).ReduceFriendFromCache(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cache.cache/UpdateFriendInfo", + FullMethod: "/cache.cache/ReduceFriendFromCache", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CacheServer).UpdateFriendInfo(ctx, req.(*UpdateFriendInfoReq)) + return srv.(CacheServer).ReduceFriendFromCache(ctx, req.(*ReduceFriendFromCacheReq)) } return interceptor(ctx, in, info, handler) } -func _Cache_UpdateBlackList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateBlackListReq) +func _Cache_GetBlackIDListFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBlackIDListFromCacheReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CacheServer).UpdateBlackList(ctx, in) + return srv.(CacheServer).GetBlackIDListFromCache(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cache.cache/UpdateBlackList", + FullMethod: "/cache.cache/GetBlackIDListFromCache", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CacheServer).UpdateBlackList(ctx, req.(*UpdateBlackListReq)) + return srv.(CacheServer).GetBlackIDListFromCache(ctx, req.(*GetBlackIDListFromCacheReq)) } return interceptor(ctx, in, info, handler) } -func _Cache_GetBlackList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBlackListReq) +func _Cache_AddBlackUserToCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddBlackUserToCacheReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CacheServer).GetBlackList(ctx, in) + return srv.(CacheServer).AddBlackUserToCache(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cache.cache/GetBlackList", + FullMethod: "/cache.cache/AddBlackUserToCache", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CacheServer).GetBlackList(ctx, req.(*GetBlackListReq)) + return srv.(CacheServer).AddBlackUserToCache(ctx, req.(*AddBlackUserToCacheReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Cache_ReduceBlackUserFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReduceBlackUserFromCacheReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CacheServer).ReduceBlackUserFromCache(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cache.cache/ReduceBlackUserFromCache", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CacheServer).ReduceBlackUserFromCache(ctx, req.(*ReduceBlackUserFromCacheReq)) } return interceptor(ctx, in, info, handler) } @@ -815,69 +1091,83 @@ var _Cache_serviceDesc = grpc.ServiceDesc{ HandlerType: (*CacheServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "GetUserInfo", - Handler: _Cache_GetUserInfo_Handler, + MethodName: "GetUserInfoFromCache", + Handler: _Cache_GetUserInfoFromCache_Handler, + }, + { + MethodName: "UpdateUserInfoToCache", + Handler: _Cache_UpdateUserInfoToCache_Handler, + }, + { + MethodName: "GetFriendIDListFromCache", + Handler: _Cache_GetFriendIDListFromCache_Handler, }, { - MethodName: "UpdateUserInfo", - Handler: _Cache_UpdateUserInfo_Handler, + MethodName: "AddFriendToCache", + Handler: _Cache_AddFriendToCache_Handler, }, { - MethodName: "GetFriendInfo", - Handler: _Cache_GetFriendInfo_Handler, + MethodName: "ReduceFriendFromCache", + Handler: _Cache_ReduceFriendFromCache_Handler, }, { - MethodName: "UpdateFriendInfo", - Handler: _Cache_UpdateFriendInfo_Handler, + MethodName: "GetBlackIDListFromCache", + Handler: _Cache_GetBlackIDListFromCache_Handler, }, { - MethodName: "UpdateBlackList", - Handler: _Cache_UpdateBlackList_Handler, + MethodName: "AddBlackUserToCache", + Handler: _Cache_AddBlackUserToCache_Handler, }, { - MethodName: "GetBlackList", - Handler: _Cache_GetBlackList_Handler, + MethodName: "ReduceBlackUserFromCache", + Handler: _Cache_ReduceBlackUserFromCache_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "cache/cache.proto", } -func init() { proto.RegisterFile("cache/cache.proto", fileDescriptor_cache_c95b22de9c135769) } - -var fileDescriptor_cache_c95b22de9c135769 = []byte{ - // 527 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0x95, 0x13, 0x35, 0x28, 0x13, 0xda, 0x34, 0x03, 0xa4, 0xc6, 0x05, 0x64, 0x7c, 0xca, 0xc9, - 0x16, 0xe1, 0x06, 0x08, 0xa4, 0xb4, 0x90, 0x46, 0x6d, 0x41, 0x5a, 0xa9, 0x17, 0x2e, 0x91, 0x9b, - 0x6c, 0x4b, 0x14, 0xe2, 0x5d, 0x76, 0xdd, 0xf6, 0xc6, 0x8d, 0x23, 0xff, 0x83, 0x9f, 0x89, 0xb2, - 0xb6, 0x93, 0xdd, 0x8d, 0x23, 0x42, 0xe0, 0x62, 0x69, 0xf6, 0xe3, 0xcd, 0x7b, 0x6f, 0xc6, 0xb3, - 0xd0, 0x1a, 0xc5, 0xa3, 0x2f, 0x34, 0x52, 0xdf, 0x90, 0x0b, 0x96, 0x32, 0xdc, 0x51, 0x81, 0xf7, - 0xfc, 0x13, 0xa7, 0xc9, 0x70, 0x70, 0x1e, 0xf1, 0xe9, 0x75, 0xa4, 0x76, 0x22, 0x39, 0x9e, 0x0e, - 0xef, 0x64, 0x74, 0x27, 0xb3, 0x93, 0xc1, 0x5b, 0x80, 0x23, 0x36, 0x9b, 0xb1, 0x84, 0x50, 0xc9, - 0xd1, 0x85, 0x7b, 0x54, 0x88, 0x23, 0x36, 0xa6, 0xae, 0xe3, 0x3b, 0x9d, 0x1d, 0x52, 0x84, 0xd8, - 0x86, 0x1a, 0x15, 0xe2, 0x5c, 0x5e, 0xbb, 0x15, 0xdf, 0xe9, 0xd4, 0x49, 0x1e, 0x05, 0x04, 0xf6, - 0xfa, 0x34, 0xbd, 0x90, 0x54, 0x0c, 0x92, 0x2b, 0x46, 0xe8, 0x37, 0x7c, 0x06, 0x70, 0x33, 0x0f, - 0x8f, 0xcf, 0x26, 0x32, 0x75, 0x1d, 0xbf, 0xda, 0xa9, 0x13, 0x6d, 0x05, 0x7d, 0x68, 0x30, 0x4e, - 0x45, 0x9c, 0x4e, 0x58, 0x32, 0x38, 0x76, 0xab, 0x0a, 0x4e, 0x5f, 0x0a, 0x7e, 0x38, 0xd0, 0x34, - 0x40, 0x25, 0xc7, 0x17, 0x00, 0xa3, 0x05, 0x4f, 0x45, 0xae, 0xd1, 0x6d, 0x85, 0x99, 0xe6, 0xa5, - 0x00, 0xa2, 0x1d, 0xc2, 0x77, 0x70, 0xff, 0x26, 0x87, 0x50, 0x54, 0x2a, 0x7e, 0xb5, 0xd3, 0xe8, - 0x1e, 0x86, 0x92, 0x8a, 0x5b, 0x2a, 0x86, 0x31, 0x9f, 0x0c, 0x79, 0x2c, 0xe2, 0x99, 0x0c, 0x17, - 0x99, 0x8c, 0x0b, 0xc1, 0x2d, 0xb4, 0x2e, 0xf8, 0x38, 0x4e, 0xa9, 0x2e, 0xcf, 0x46, 0x75, 0xfe, - 0x12, 0xd5, 0xd6, 0x5f, 0x59, 0xd5, 0xdf, 0x07, 0xb4, 0xf3, 0x6e, 0xe5, 0x40, 0x70, 0x06, 0xfb, - 0x7d, 0x9a, 0x7e, 0x10, 0x13, 0x9a, 0x8c, 0x0b, 0xfe, 0x6d, 0xa8, 0x65, 0xc5, 0x50, 0x10, 0x75, - 0x92, 0x47, 0x1b, 0xd0, 0xfa, 0xe9, 0x40, 0xcb, 0x82, 0x93, 0x1c, 0xdf, 0xc3, 0xde, 0xd5, 0x62, - 0x45, 0x73, 0xe4, 0x69, 0x89, 0x23, 0xda, 0x55, 0xeb, 0x92, 0xa5, 0xae, 0xb2, 0x89, 0x3a, 0x51, - 0xd8, 0xd4, 0xfb, 0x1a, 0x8f, 0xa6, 0x73, 0x94, 0xb9, 0xbe, 0x57, 0x50, 0xbf, 0x2c, 0xe2, 0x9c, - 0xca, 0x93, 0x12, 0x2a, 0xea, 0x8e, 0x62, 0xb2, 0x3c, 0xbe, 0x81, 0x07, 0x27, 0xf0, 0x60, 0x25, - 0xe7, 0x76, 0xb5, 0x39, 0x55, 0x3d, 0x6e, 0x50, 0xdf, 0xbe, 0x34, 0x1f, 0x55, 0xa1, 0x4d, 0x4e, - 0xff, 0x60, 0x44, 0xf0, 0xbd, 0x90, 0x69, 0xf6, 0xce, 0x7f, 0xaa, 0xf5, 0x9f, 0xf5, 0x0c, 0xe0, - 0xe1, 0x6a, 0xfe, 0xad, 0x7c, 0xee, 0xfe, 0xaa, 0x42, 0x36, 0x0d, 0xf1, 0x0d, 0x34, 0xb4, 0xa9, - 0x82, 0x8f, 0xf2, 0x7b, 0xe6, 0xf8, 0xf2, 0xda, 0x65, 0xcb, 0x59, 0x9f, 0x9b, 0x3f, 0x25, 0xba, - 0xf9, 0xc9, 0x95, 0x19, 0xe1, 0x3d, 0x5e, 0xb3, 0x23, 0x39, 0xf6, 0x60, 0xd7, 0xf8, 0x87, 0xf0, - 0x60, 0x99, 0xcf, 0x30, 0xdb, 0x73, 0xcb, 0x37, 0x24, 0xc7, 0x53, 0xd8, 0xb7, 0xdd, 0x41, 0xcf, - 0x48, 0x69, 0x22, 0x1d, 0xae, 0xdd, 0x93, 0x1c, 0x4f, 0xa0, 0x69, 0x75, 0x34, 0x9a, 0xf4, 0xf5, - 0x16, 0xf5, 0xbc, 0x75, 0x5b, 0xd9, 0xbc, 0xd5, 0x9b, 0x10, 0x35, 0x27, 0x0d, 0x8c, 0x83, 0xd2, - 0x75, 0xc9, 0x7b, 0xcd, 0xcf, 0xbb, 0x61, 0xf6, 0x8c, 0xbd, 0x56, 0xdf, 0xcb, 0x9a, 0x7a, 0xa3, - 0x5e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xb4, 0x17, 0x6d, 0x42, 0xe2, 0x06, 0x00, 0x00, +func init() { proto.RegisterFile("cache/cache.proto", fileDescriptor_cache_d0822f7e413e82c3) } + +var fileDescriptor_cache_d0822f7e413e82c3 = []byte{ + // 619 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdf, 0x6e, 0xd3, 0x3e, + 0x14, 0x56, 0x5a, 0xb5, 0xbf, 0x5f, 0x4f, 0x41, 0x30, 0x33, 0xba, 0xcc, 0x1d, 0x25, 0x0b, 0x37, + 0xbd, 0x6a, 0x45, 0xb9, 0x44, 0x02, 0x6d, 0x9d, 0x56, 0x55, 0x6c, 0x43, 0x44, 0x1b, 0x93, 0xc6, + 0x45, 0xc9, 0x12, 0x6f, 0x54, 0xa5, 0xb5, 0x67, 0xa7, 0x4c, 0x5c, 0xf0, 0x0a, 0xbc, 0x26, 0xaf, + 0x81, 0x6a, 0xa7, 0xe9, 0x9f, 0xd9, 0x6d, 0xc8, 0xe0, 0x26, 0x92, 0xed, 0x93, 0xef, 0x9c, 0xef, + 0x7c, 0xe7, 0x1c, 0x1b, 0x36, 0x02, 0x3f, 0xf8, 0x42, 0x9a, 0xf2, 0xdb, 0x60, 0x9c, 0x46, 0x14, + 0x15, 0xe4, 0x02, 0xef, 0xbe, 0x67, 0x64, 0xd4, 0xeb, 0x1e, 0x37, 0xd9, 0xe0, 0xba, 0x29, 0x4f, + 0x9a, 0x22, 0x1c, 0xf4, 0x6e, 0x45, 0xf3, 0x56, 0x28, 0x4b, 0xf7, 0x0d, 0x40, 0x9b, 0x0e, 0x87, + 0x74, 0xe4, 0x11, 0xc1, 0x90, 0x0d, 0xff, 0x11, 0xce, 0xdb, 0x34, 0x24, 0xb6, 0xe5, 0x58, 0xf5, + 0x82, 0x37, 0x5d, 0xa2, 0x0a, 0x14, 0x09, 0xe7, 0xc7, 0xe2, 0xda, 0xce, 0x39, 0x56, 0xbd, 0xe4, + 0xc5, 0x2b, 0xf7, 0x13, 0x6c, 0x75, 0x48, 0x74, 0x26, 0x08, 0xef, 0x8e, 0xae, 0xe8, 0x21, 0xa7, + 0xc3, 0xf6, 0xc4, 0xb5, 0x47, 0x6e, 0x50, 0x0d, 0x60, 0x3c, 0xd9, 0x3f, 0x38, 0xea, 0x8b, 0xc8, + 0xb6, 0x9c, 0x7c, 0xbd, 0xe4, 0xcd, 0xed, 0x20, 0x07, 0xca, 0x94, 0x11, 0xee, 0x47, 0x7d, 0x3a, + 0xea, 0x1e, 0xc4, 0xb8, 0xf3, 0x5b, 0xee, 0x4f, 0x0b, 0x6c, 0x3d, 0xba, 0x60, 0xe8, 0x25, 0x40, + 0x90, 0x44, 0x2e, 0xc3, 0x2d, 0xb7, 0x36, 0x1a, 0x2a, 0x0b, 0x33, 0x4a, 0xde, 0x9c, 0x11, 0x7a, + 0x0b, 0x0f, 0xc6, 0x31, 0x96, 0x8c, 0x29, 0xe7, 0xe4, 0xeb, 0xe5, 0x56, 0xb5, 0x21, 0x08, 0xff, + 0x46, 0x78, 0xcf, 0x67, 0xfd, 0x1e, 0xf3, 0xb9, 0x3f, 0x14, 0x8d, 0xa9, 0x4b, 0x6f, 0xe1, 0x07, + 0xf7, 0x07, 0xd8, 0x67, 0x2c, 0xf4, 0x23, 0x32, 0x3d, 0x3f, 0xa5, 0x09, 0xdd, 0x65, 0x70, 0xeb, + 0x0f, 0xc1, 0x53, 0xe4, 0xe3, 0x04, 0xb6, 0x0d, 0xee, 0x33, 0xe5, 0xc3, 0x3d, 0x87, 0x6a, 0x87, + 0x44, 0x87, 0xbc, 0x4f, 0x46, 0xa1, 0x12, 0x65, 0x41, 0xc0, 0x0a, 0x14, 0x95, 0x5c, 0x12, 0xad, + 0xe4, 0xc5, 0xab, 0x14, 0x81, 0xde, 0xc0, 0x8e, 0x19, 0x58, 0xb0, 0xb5, 0xa5, 0xb1, 0xc8, 0x25, + 0x97, 0x86, 0xcb, 0x00, 0x9e, 0xec, 0x85, 0xa1, 0x72, 0x39, 0xa7, 0x8a, 0x89, 0x03, 0x86, 0xff, + 0xaf, 0xe2, 0xf0, 0x62, 0x02, 0xc9, 0x7a, 0x99, 0x5f, 0xfe, 0x2e, 0xbf, 0x2e, 0x6c, 0xde, 0x75, + 0x96, 0x4d, 0x03, 0x06, 0xb6, 0x47, 0xc2, 0x71, 0x40, 0x14, 0x5a, 0x2a, 0x01, 0xee, 0x17, 0xfc, + 0x09, 0x6c, 0x1b, 0x3c, 0x66, 0x63, 0xf0, 0x11, 0x70, 0x87, 0x44, 0xfb, 0x5f, 0xfd, 0x60, 0xf0, + 0x57, 0x8b, 0x88, 0xc9, 0xea, 0xd4, 0xe3, 0xfe, 0x9b, 0x1a, 0x8a, 0xa0, 0xb2, 0x17, 0x86, 0xd2, + 0xe3, 0xa4, 0xc3, 0x52, 0x94, 0x91, 0x03, 0xe5, 0xcb, 0xa9, 0xf9, 0x8c, 0xc5, 0xdc, 0x56, 0x0a, + 0x3d, 0x8e, 0x60, 0x4b, 0xeb, 0x35, 0x9b, 0x1a, 0xdf, 0xa1, 0xaa, 0xd4, 0x4d, 0x00, 0xd3, 0xca, + 0x71, 0x6f, 0x22, 0x1f, 0x60, 0xc7, 0xec, 0x3a, 0x13, 0x9b, 0xd6, 0xaf, 0x02, 0xa8, 0xbb, 0x0c, + 0x9d, 0xc3, 0xa6, 0xee, 0x2a, 0x40, 0xb5, 0x18, 0xc0, 0x70, 0x0b, 0xe1, 0xe7, 0x2b, 0xcf, 0x05, + 0x43, 0x17, 0xf0, 0x54, 0x3b, 0x54, 0xd1, 0xf4, 0x4f, 0xd3, 0xc4, 0xc7, 0xce, 0x6a, 0x03, 0xc1, + 0x50, 0x20, 0xef, 0x2f, 0xed, 0x1c, 0x44, 0xee, 0x2c, 0x30, 0xd3, 0x04, 0xc6, 0x2f, 0xd6, 0xda, + 0x08, 0x86, 0xde, 0xc1, 0xe3, 0xe5, 0x61, 0x84, 0x70, 0xfc, 0xa3, 0x66, 0x24, 0xe2, 0xaa, 0xf1, + 0x4c, 0x65, 0x43, 0x3b, 0x1c, 0x92, 0x6c, 0x98, 0x86, 0x55, 0x92, 0x0d, 0xf3, 0x6c, 0xf9, 0x2c, + 0xdf, 0x0a, 0xba, 0x86, 0x46, 0xbb, 0x33, 0xa2, 0x86, 0x41, 0x82, 0xdd, 0x75, 0x26, 0x82, 0xa1, + 0x53, 0x79, 0x09, 0x2c, 0xb7, 0x12, 0x7a, 0x36, 0x63, 0xac, 0x69, 0x6e, 0x5c, 0x5b, 0x75, 0xac, + 0x54, 0x34, 0xd5, 0x75, 0xa2, 0xe2, 0x8a, 0x9e, 0x4b, 0x54, 0x5c, 0xd5, 0x1c, 0xfb, 0x8f, 0x2e, + 0x1e, 0x36, 0xd4, 0x1b, 0xee, 0xb5, 0xfc, 0x5e, 0x16, 0xe5, 0x03, 0xed, 0xd5, 0xef, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x08, 0x5c, 0x1d, 0xa2, 0xdf, 0x09, 0x00, 0x00, } diff --git a/pkg/proto/cache/cache.proto b/pkg/proto/cache/cache.proto index e5da4efa7..de102ce5a 100644 --- a/pkg/proto/cache/cache.proto +++ b/pkg/proto/cache/cache.proto @@ -8,71 +8,100 @@ message CommonResp{ string errMsg = 2; } -message GetUserInfoReq{ +message GetUserInfoFromCacheReq{ repeated string userIDList = 1; - string operationID = 3; + string operationID = 2; } -message GetUserInfoResp{ +message GetUserInfoFromCacheResp{ CommonResp commonResp = 1; repeated server_api_params.UserInfo userInfoList = 2; } -message UpdateUserInfoReq{ +message UpdateUserInfoToCacheReq{ repeated server_api_params.UserInfo userInfoList = 1; string operationID = 2; } -message UpdateUserInfoResp{ +message UpdateUserInfoToCacheResp{ CommonResp commonResp = 1; } -message GetFriendInfoReq { +message GetFriendIDListFromCacheReq { string userID = 1; string operationID = 2; } -message GetFriendInfoResp { - repeated server_api_params.FriendInfo friendInfoList = 1; +message GetFriendIDListFromCacheResp { + repeated string userIDList = 1; CommonResp commonResp = 2; } -message UpdateBlackListReq { - repeated server_api_params.BlackInfo blackList = 1; - string operationID = 2; +message AddFriendToCacheReq { + string userID = 1; + string friendID = 2; + string operationID = 3; +} + +message AddFriendToCacheResp { + CommonResp commonResp = 1; } -message UpdateBlackListResp { +message ReduceFriendFromCacheReq { + string userID = 1; + string friendID = 2; + string operationID = 3; +} + +message ReduceFriendFromCacheResp { CommonResp commonResp = 1; } -message GetBlackListReq { +message GetBlackIDListFromCacheReq { string userID = 1; string operationID = 2; } -message GetBlackListResp { - repeated server_api_params.BlackInfo blackList = 1; +message GetBlackIDListFromCacheResp { + repeated string userIDList = 1; + CommonResp commonResp = 2; +} + +message AddBlackUserToCacheReq { + string userID = 1; + string blackUserID = 2; + string operationID = 3; } +message AddBlackUserToCacheResp { + CommonResp commonResp = 1; +} -message UpdateFriendInfoReq{ - repeated server_api_params.FriendInfo friendInfoList = 1; - string operationID = 2; +message ReduceBlackUserFromCacheReq { + string userID = 1; + string blackUserID = 2; + string operationID = 3; } -message UpdateFriendInfoResp{ +message ReduceBlackUserFromCacheResp { CommonResp commonResp = 1; } service cache{ - rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp); - rpc UpdateUserInfo(UpdateUserInfoReq) returns(UpdateUserInfoResp); - rpc GetFriendInfo(GetFriendInfoReq) returns(GetFriendInfoResp); - rpc UpdateFriendInfo(UpdateFriendInfoReq) returns(UpdateFriendInfoResp); - rpc UpdateBlackList(UpdateBlackListReq) returns(UpdateBlackListResp); - rpc GetBlackList(GetBlackListReq) returns(GetBlackListResp); + // userInfo + rpc GetUserInfoFromCache(GetUserInfoFromCacheReq) returns(GetUserInfoFromCacheResp); + rpc UpdateUserInfoToCache(UpdateUserInfoToCacheReq) returns(UpdateUserInfoToCacheResp); + + // friendInfo + rpc GetFriendIDListFromCache(GetFriendIDListFromCacheReq) returns(GetFriendIDListFromCacheResp); + rpc AddFriendToCache(AddFriendToCacheReq) returns(AddFriendToCacheResp); + rpc ReduceFriendFromCache(ReduceFriendFromCacheReq) returns(ReduceFriendFromCacheResp); + + // blackList + rpc GetBlackIDListFromCache(GetBlackIDListFromCacheReq) returns(GetBlackIDListFromCacheResp); + rpc AddBlackUserToCache(AddBlackUserToCacheReq) returns(AddBlackUserToCacheResp); + rpc ReduceBlackUserFromCache(ReduceBlackUserFromCacheReq) returns(ReduceBlackUserFromCacheResp); } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 52cb1bf2e..86b1be180 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -1,6 +1,10 @@ package utils import ( + "bytes" + "encoding/json" + "github.com/gogo/protobuf/jsonpb" + "github.com/golang/protobuf/proto" "github.com/jinzhu/copier" "github.com/pkg/errors" "math/rand" @@ -131,3 +135,18 @@ func RemoveRepeatedStringInList(slc []string) []string { } return result } + +func Pb2Map(pb proto.Message) (map[string]interface{}, error) { + _buffer := bytes.Buffer{} + jsonbMarshaller := &jsonpb.Marshaler{ + OrigName: true, + EnumsAsInts: true, + EmitDefaults: true, + } + _ = jsonbMarshaller.Marshal(&_buffer, pb) + jsonCnt := _buffer.Bytes() + var out map[string]interface{} + err := json.Unmarshal(jsonCnt, &out) + + return out, err +}