Merge remote-tracking branch 'origin/errcode' into errcode

# Conflicts:
#	internal/utils/convert.go
This commit is contained in:
skiffer-git 2023-01-29 14:48:05 +08:00
commit 7b0eeb3049
17 changed files with 258 additions and 1278 deletions

View File

@ -1,145 +0,0 @@
package cache
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
rocksCache "Open_IM/pkg/common/db/rocks_cache"
"Open_IM/pkg/common/log"
promePkg "Open_IM/pkg/common/prometheus"
pbCache "Open_IM/pkg/proto/cache"
"Open_IM/pkg/utils"
"context"
"github.com/OpenIMSDK/getcdv3"
"net"
"strconv"
"strings"
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"google.golang.org/grpc"
)
type cacheServer struct {
rpcPort int
rpcRegisterName string
etcdSchema string
etcdAddr []string
}
func NewCacheServer(port int) *cacheServer {
log.NewPrivateLog(constant.LogFileName)
return &cacheServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImCacheName,
etcdSchema: config.Config.Etcd.EtcdSchema,
etcdAddr: config.Config.Etcd.EtcdAddr,
}
}
func (s *cacheServer) Run() {
log.NewInfo("0", "cacheServer rpc start ")
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
var grpcOpts []grpc.ServerOption
if config.Config.Prometheus.Enable {
promePkg.NewGrpcRequestCounter()
promePkg.NewGrpcRequestFailedCounter()
promePkg.NewGrpcRequestSuccessCounter()
grpcOpts = append(grpcOpts, []grpc.ServerOption{
// grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme),
grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor),
grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor),
}...)
}
srv := grpc.NewServer(grpcOpts...)
defer srv.GracefulStop()
pbCache.RegisterCacheServer(srv, s)
rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10, "")
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
panic(utils.Wrap(err, "register cache module rpc to etcd err"))
}
go rocksCache.DelKeys()
err = srv.Serve(listener)
if err != nil {
log.NewError("0", "Serve failed ", err.Error())
return
}
log.NewInfo("0", "message cms rpc success")
}
func (s *cacheServer) GetFriendIDListFromCache(ctx context.Context, req *pbCache.GetFriendIDListFromCacheReq) (resp *pbCache.GetFriendIDListFromCacheResp, err error) {
resp = &pbCache.GetFriendIDListFromCacheResp{}
friendIDList, err := rocksCache.GetFriendIDListFromCache(ctx, req.UserID)
if err != nil {
return
}
resp.UserIDList = friendIDList
return
}
// this is for dtm call
func (s *cacheServer) DelFriendIDListFromCache(ctx context.Context, req *pbCache.DelFriendIDListFromCacheReq) (resp *pbCache.DelFriendIDListFromCacheResp, err error) {
resp = &pbCache.DelFriendIDListFromCacheResp{}
if err := rocksCache.DelFriendIDListFromCache(ctx, req.UserID); err != nil {
return
}
return
}
func (s *cacheServer) GetBlackIDListFromCache(ctx context.Context, req *pbCache.GetBlackIDListFromCacheReq) (resp *pbCache.GetBlackIDListFromCacheResp, err error) {
resp = &pbCache.GetBlackIDListFromCacheResp{}
blackUserIDList, err := rocksCache.GetBlackListFromCache(ctx, req.UserID)
if err != nil {
return
}
resp.UserIDList = blackUserIDList
return
}
func (s *cacheServer) DelBlackIDListFromCache(ctx context.Context, req *pbCache.DelBlackIDListFromCacheReq) (resp *pbCache.DelBlackIDListFromCacheResp, err error) {
resp = &pbCache.DelBlackIDListFromCacheResp{}
if err := rocksCache.DelBlackIDListFromCache(ctx, req.UserID); err != nil {
return
}
return resp, nil
}
func (s *cacheServer) GetGroupMemberIDListFromCache(ctx context.Context, req *pbCache.GetGroupMemberIDListFromCacheReq) (resp *pbCache.GetGroupMemberIDListFromCacheResp, err error) {
resp = &pbCache.GetGroupMemberIDListFromCacheResp{}
userIDList, err := rocksCache.GetGroupMemberIDListFromCache(ctx, req.GroupID)
if err != nil {
return
}
resp.UserIDList = userIDList
return
}
func (s *cacheServer) DelGroupMemberIDListFromCache(ctx context.Context, req *pbCache.DelGroupMemberIDListFromCacheReq) (resp *pbCache.DelGroupMemberIDListFromCacheResp, err error) {
resp = &pbCache.DelGroupMemberIDListFromCacheResp{}
if err := rocksCache.DelGroupMemberIDListFromCache(ctx, req.GroupID); err != nil {
return resp, nil
}
return resp, nil
}

View File

@ -58,6 +58,7 @@ func NewGroupServer(port int) *groupServer {
var mysql relation.Mysql var mysql relation.Mysql
var mongo unrelation.Mongo var mongo unrelation.Mongo
var groupModel relation.Group var groupModel relation.Group
var redis cache.RedisClient
err := mysql.InitConn().AutoMigrateModel(&groupModel) err := mysql.InitConn().AutoMigrateModel(&groupModel)
if err != nil { if err != nil {
panic("db init err:" + err.Error()) panic("db init err:" + err.Error())
@ -68,8 +69,9 @@ func NewGroupServer(port int) *groupServer {
panic("db init err:" + "conn is nil") panic("db init err:" + "conn is nil")
} }
mongo.InitMongo() mongo.InitMongo()
redis.InitRedis()
mongo.CreateSuperGroupIndex() mongo.CreateSuperGroupIndex()
g.GroupInterface = controller.NewGroupController(groupModel.DB, cache.InitRedis(), mongo.DB) g.GroupInterface = controller.NewGroupController(groupModel.DB, redis.GetClient(), mongo.GetClient())
return &g return &g
} }
@ -166,6 +168,9 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
if err := callbackBeforeCreateGroup(ctx, req); err != nil { if err := callbackBeforeCreateGroup(ctx, req); err != nil {
return nil, err return nil, err
} }
var groupInfo relation.Group
utils.CopyStructFields(&groupInfo, req.GroupInfo)
groupInfo, err := (&cp.PBGroup{req.GroupInfo}).Convert() groupInfo, err := (&cp.PBGroup{req.GroupInfo}).Convert()
groupInfo.GroupID = genGroupID(ctx, req.GroupInfo.GroupID) groupInfo.GroupID = genGroupID(ctx, req.GroupInfo.GroupID)
if req.GroupInfo.GroupType != constant.SuperGroup { if req.GroupInfo.GroupType != constant.SuperGroup {

View File

@ -1,7 +1,7 @@
package utils package utils
import ( import (
imdb "Open_IM/pkg/common/db/relation" "Open_IM/pkg/common/db/relation"
sdk "Open_IM/pkg/proto/sdk_ws" sdk "Open_IM/pkg/proto/sdk_ws"
utils2 "Open_IM/pkg/utils" utils2 "Open_IM/pkg/utils"
utils "github.com/OpenIMSDK/open_utils" utils "github.com/OpenIMSDK/open_utils"
@ -20,7 +20,7 @@ func getNumberOfGroupMember(groupID string) (int32, error) {
} }
type DBFriend struct { type DBFriend struct {
*imdb.Friend *relation.Friend
} }
type PBFriend struct { type PBFriend struct {
@ -41,8 +41,8 @@ func (db *DBFriend) convert() (*sdk.FriendInfo, error) {
return pbFriend, nil return pbFriend, nil
} }
func (pb *PBFriend) Convert() (*imdb.Friend, error) { func (pb *PBFriend) Convert() (*relation.Friend, error) {
dbFriend := &imdb.Friend{} dbFriend := &relation.Friend{}
utils2.CopyStructFields(dbFriend, pb) utils2.CopyStructFields(dbFriend, pb)
dbFriend.FriendUserID = pb.FriendUser.UserID dbFriend.FriendUserID = pb.FriendUser.UserID
dbFriend.CreateTime = utils2.UnixSecondToTime(int64(pb.CreateTime)) dbFriend.CreateTime = utils2.UnixSecondToTime(int64(pb.CreateTime))
@ -50,15 +50,15 @@ func (pb *PBFriend) Convert() (*imdb.Friend, error) {
} }
type DBFriendRequest struct { type DBFriendRequest struct {
*imdb.FriendRequest *relation.FriendRequest
} }
type PBFriendRequest struct { type PBFriendRequest struct {
*sdk.FriendRequest *sdk.FriendRequest
} }
func (pb *PBFriendRequest) Convert() (*imdb.FriendRequest, error) { func (pb *PBFriendRequest) Convert() (*relation.FriendRequest, error) {
dbFriendRequest := &imdb.FriendRequest{} dbFriendRequest := &relation.FriendRequest{}
utils.CopyStructFields(dbFriendRequest, pb) utils.CopyStructFields(dbFriendRequest, pb)
dbFriendRequest.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime)) dbFriendRequest.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime))
dbFriendRequest.HandleTime = utils.UnixSecondToTime(int64(pb.HandleTime)) dbFriendRequest.HandleTime = utils.UnixSecondToTime(int64(pb.HandleTime))
@ -87,15 +87,15 @@ func (db *DBFriendRequest) Convert() (*sdk.FriendRequest, error) {
} }
type DBBlack struct { type DBBlack struct {
*imdb.Black *relation.Black
} }
type PBBlack struct { type PBBlack struct {
*sdk.BlackInfo *sdk.BlackInfo
} }
func (pb *PBBlack) Convert() (*imdb.Black, error) { func (pb *PBBlack) Convert() (*relation.Black, error) {
dbBlack := &imdb.Black{} dbBlack := &relation.Black{}
dbBlack.BlockUserID = pb.BlackUserInfo.UserID dbBlack.BlockUserID = pb.BlackUserInfo.UserID
dbBlack.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime)) dbBlack.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime))
return dbBlack, nil return dbBlack, nil
@ -113,17 +113,17 @@ func (db *DBBlack) Convert() (*sdk.BlackInfo, error) {
} }
type DBGroup struct { type DBGroup struct {
*imdb.Group *relation.Group
} }
type PBGroup struct { type PBGroup struct {
*sdk.GroupInfo *sdk.GroupInfo
} }
func (pb *PBGroup) Convert() (*imdb.Group, error) { func (pb *PBGroup) Convert() *relation.Group {
dst := &imdb.Group{} dst := &relation.Group{}
utils.CopyStructFields(dst, pb) _ = utils.CopyStructFields(dst, pb)
return dst, nil return dst
} }
func (db *DBGroup) Convert() (*sdk.GroupInfo, error) { func (db *DBGroup) Convert() (*sdk.GroupInfo, error) {
dst := &sdk.GroupInfo{} dst := &sdk.GroupInfo{}
@ -148,15 +148,15 @@ func (db *DBGroup) Convert() (*sdk.GroupInfo, error) {
} }
type DBGroupMember struct { type DBGroupMember struct {
*imdb.GroupMember *relation.GroupMember
} }
type PBGroupMember struct { type PBGroupMember struct {
*sdk.GroupMemberFullInfo *sdk.GroupMemberFullInfo
} }
func (pb *PBGroupMember) Convert() (*imdb.GroupMember, error) { func (pb *PBGroupMember) Convert() (*relation.GroupMember, error) {
dst := &imdb.GroupMember{} dst := &relation.GroupMember{}
utils.CopyStructFields(dst, pb) utils.CopyStructFields(dst, pb)
dst.JoinTime = utils.UnixSecondToTime(int64(pb.JoinTime)) dst.JoinTime = utils.UnixSecondToTime(int64(pb.JoinTime))
dst.MuteEndTime = utils.UnixSecondToTime(int64(pb.MuteEndTime)) dst.MuteEndTime = utils.UnixSecondToTime(int64(pb.MuteEndTime))
@ -184,15 +184,15 @@ func (db *DBGroupMember) Convert() (*sdk.GroupMemberFullInfo, error) {
} }
type DBGroupRequest struct { type DBGroupRequest struct {
*imdb.GroupRequest *relation.GroupRequest
} }
type PBGroupRequest struct { type PBGroupRequest struct {
*sdk.GroupRequest *sdk.GroupRequest
} }
func (pb *PBGroupRequest) Convert() (*imdb.GroupRequest, error) { func (pb *PBGroupRequest) Convert() (*relation.GroupRequest, error) {
dst := &imdb.GroupRequest{} dst := &relation.GroupRequest{}
utils.CopyStructFields(dst, pb) utils.CopyStructFields(dst, pb)
dst.ReqTime = utils.UnixSecondToTime(int64(pb.ReqTime)) dst.ReqTime = utils.UnixSecondToTime(int64(pb.ReqTime))
dst.HandledTime = utils.UnixSecondToTime(int64(pb.HandleTime)) dst.HandledTime = utils.UnixSecondToTime(int64(pb.HandleTime))
@ -207,23 +207,15 @@ func (db *DBGroupRequest) Convert() (*sdk.GroupRequest, error) {
} }
type DBUser struct { type DBUser struct {
*imdb.User *relation.User
}
func NewDBUser(user *imdb.User) *DBUser {
return &DBUser{User: user}
} }
type PBUser struct { type PBUser struct {
*sdk.UserInfo *sdk.UserInfo
} }
func NewPBUser(userInfo *sdk.UserInfo) *PBUser { func (pb *PBUser) Convert() (*relation.User, error) {
return &PBUser{UserInfo: userInfo} dst := &relation.User{}
}
func (pb *PBUser) Convert() (*imdb.User, error) {
dst := &imdb.User{}
utils.CopyStructFields(dst, pb) utils.CopyStructFields(dst, pb)
dst.Birth = utils.UnixSecondToTime(pb.Birthday) dst.Birth = utils.UnixSecondToTime(pb.Birthday)
dst.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime)) dst.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime))

View File

@ -15,23 +15,25 @@ const GroupExpireTime = time.Second * 60 * 60 * 12
const groupInfoCacheKey = "GROUP_INFO_CACHE:" const groupInfoCacheKey = "GROUP_INFO_CACHE:"
type GroupCache struct { type GroupCache struct {
db *relation.Group group *relation.Group
expireTime time.Duration groupMember *relation.GroupMember
redisClient *RedisClient groupRequest *relation.GroupRequest
rcClient *rockscache.Client expireTime time.Duration
redisClient *RedisClient
rcClient *rockscache.Client
} }
func NewGroupCache(rdb redis.UniversalClient, db *relation.Group, opts rockscache.Options) *GroupCache { func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.Group, groupMemberDB *relation.GroupMember, groupRequestDB *relation.GroupRequest, opts rockscache.Options) *GroupCache {
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: GroupExpireTime, db: db, redisClient: NewRedisClient(rdb)} return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: GroupExpireTime, group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb)}
} }
func (g *GroupCache) getRedisClient() *RedisClient { func (g *GroupCache) getRedisClient() *RedisClient {
return g.redisClient return g.redisClient
} }
func (g *GroupCache) GetGroupsInfoFromCache(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) { func (g *GroupCache) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
for _, groupID := range groupIDs { for _, groupID := range groupIDs {
group, err := g.GetGroupInfoFromCache(ctx, groupID) group, err := g.GetGroupInfo(ctx, groupID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -40,9 +42,9 @@ func (g *GroupCache) GetGroupsInfoFromCache(ctx context.Context, groupIDs []stri
return groups, nil return groups, nil
} }
func (g *GroupCache) GetGroupInfoFromCache(ctx context.Context, groupID string) (group *relation.Group, err error) { func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *relation.Group, err error) {
getGroup := func() (string, error) { getGroup := func() (string, error) {
groupInfo, err := g.db.Take(ctx, groupID) groupInfo, err := g.group.Take(ctx, groupID)
if err != nil { if err != nil {
return "", utils.Wrap(err, "") return "", utils.Wrap(err, "")
} }
@ -64,16 +66,16 @@ func (g *GroupCache) GetGroupInfoFromCache(ctx context.Context, groupID string)
return group, utils.Wrap(err, "") return group, utils.Wrap(err, "")
} }
func (g *GroupCache) DelGroupInfoFromCache(ctx context.Context, groupID string) (err error) { func (g *GroupCache) DelGroupInfo(ctx context.Context, groupID string) (err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}() }()
return g.rcClient.TagAsDeleted(g.getGroupInfoCacheKey(groupID)) return g.rcClient.TagAsDeleted(g.getGroupInfoCacheKey(groupID))
} }
func (g *GroupCache) DelGroupsInfoFromCache(ctx context.Context, groupIDs []string) error { func (g *GroupCache) DelGroupsInfo(ctx context.Context, groupIDs []string) error {
for _, groupID := range groupIDs { for _, groupID := range groupIDs {
if err := g.DelGroupInfoFromCache(ctx, groupID); err != nil { if err := g.DelGroupInfo(ctx, groupID); err != nil {
return err return err
} }
} }
@ -83,3 +85,18 @@ func (g *GroupCache) DelGroupsInfoFromCache(ctx context.Context, groupIDs []stri
func (g *GroupCache) getGroupInfoCacheKey(groupID string) string { func (g *GroupCache) getGroupInfoCacheKey(groupID string) string {
return groupInfoCacheKey + groupID return groupInfoCacheKey + groupID
} }
func (g *GroupCache) DelJoinedSuperGroupIDs(ctx context.Context, userIDs []string) (err error) {
for _, userID := range userIDs {
if err := g.rcClient.TagAsDeleted(joinedSuperGroupListCache + userID); err != nil {
return err
}
}
}
func (g *GroupCache) DelJoinedSuperGroupID(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return g.rcClient.TagAsDeleted(joinedSuperGroupListCache + userID)
}

View File

@ -14,7 +14,7 @@ import (
"strconv" "strconv"
"time" "time"
go_redis "github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
@ -42,12 +42,16 @@ const (
exTypeKeyLocker = "EX_LOCK:" exTypeKeyLocker = "EX_LOCK:"
) )
func InitRedis() go_redis.UniversalClient { type RedisClient struct {
var rdb go_redis.UniversalClient rdb redis.UniversalClient
}
func (r *RedisClient) InitRedis() {
var rdb redis.UniversalClient
var err error var err error
ctx := context.Background() ctx := context.Background()
if config.Config.Redis.EnableCluster { if config.Config.Redis.EnableCluster {
rdb = go_redis.NewClusterClient(&go_redis.ClusterOptions{ rdb = redis.NewClusterClient(&redis.ClusterOptions{
Addrs: config.Config.Redis.DBAddress, Addrs: config.Config.Redis.DBAddress,
Username: config.Config.Redis.DBUserName, Username: config.Config.Redis.DBUserName,
Password: config.Config.Redis.DBPassWord, // no password set Password: config.Config.Redis.DBPassWord, // no password set
@ -59,7 +63,7 @@ func InitRedis() go_redis.UniversalClient {
panic(err.Error() + " redis cluster " + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) panic(err.Error() + " redis cluster " + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord)
} }
} else { } else {
rdb = go_redis.NewClient(&go_redis.Options{ rdb = redis.NewClient(&redis.Options{
Addr: config.Config.Redis.DBAddress[0], Addr: config.Config.Redis.DBAddress[0],
Username: config.Config.Redis.DBUserName, Username: config.Config.Redis.DBUserName,
Password: config.Config.Redis.DBPassWord, // no password set Password: config.Config.Redis.DBPassWord, // no password set
@ -71,14 +75,14 @@ func InitRedis() go_redis.UniversalClient {
panic(err.Error() + " redis " + config.Config.Redis.DBAddress[0] + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) panic(err.Error() + " redis " + config.Config.Redis.DBAddress[0] + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord)
} }
} }
return rdb r.rdb = rdb
} }
type RedisClient struct { func (r *RedisClient) GetClient() redis.UniversalClient {
rdb go_redis.UniversalClient return r.rdb
} }
func NewRedisClient(rdb go_redis.UniversalClient) *RedisClient { func NewRedisClient(rdb redis.UniversalClient) *RedisClient {
return &RedisClient{rdb: rdb} return &RedisClient{rdb: rdb}
} }
@ -213,7 +217,7 @@ func (r *RedisClient) GetUserGlobalMsgRecvOpt(userID string) (int, error) {
key := conversationReceiveMessageOpt + userID key := conversationReceiveMessageOpt + userID
result, err := r.rdb.HGet(context.Background(), key, GlobalMsgRecvOpt).Result() result, err := r.rdb.HGet(context.Background(), key, GlobalMsgRecvOpt).Result()
if err != nil { if err != nil {
if err == go_redis.Nil { if err == redis.Nil {
return 0, nil return 0, nil
} else { } else {
return 0, err return 0, err
@ -289,7 +293,7 @@ func (r *RedisClient) CleanUpOneUserAllMsgFromRedis(userID string, operationID s
key := messageCache + userID + "_" + "*" key := messageCache + userID + "_" + "*"
vals, err := r.rdb.Keys(ctx, key).Result() vals, err := r.rdb.Keys(ctx, key).Result()
log2.Debug(operationID, "vals: ", vals) log2.Debug(operationID, "vals: ", vals)
if err == go_redis.Nil { if err == redis.Nil {
return nil return nil
} }
if err != nil { if err != nil {
@ -407,7 +411,7 @@ func (r *RedisClient) DelMsgFromCache(uid string, seqList []uint32, operationID
key := messageCache + uid + "_" + strconv.Itoa(int(seq)) key := messageCache + uid + "_" + strconv.Itoa(int(seq))
result, err := r.rdb.Get(context.Background(), key).Result() result, err := r.rdb.Get(context.Background(), key).Result()
if err != nil { if err != nil {
if err == go_redis.Nil { if err == redis.Nil {
log2.NewDebug(operationID, utils.GetSelfFuncName(), err.Error(), "redis nil") log2.NewDebug(operationID, utils.GetSelfFuncName(), err.Error(), "redis nil")
} else { } else {
log2.NewError(operationID, utils.GetSelfFuncName(), err.Error(), key) log2.NewError(operationID, utils.GetSelfFuncName(), err.Error(), key)

View File

@ -19,6 +19,7 @@ type GroupInterface interface {
TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error)
//mongo //mongo
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string, memberNumCount int) error
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error)
} }
@ -26,7 +27,7 @@ type GroupController struct {
database DataBase database DataBase
} }
func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Database) GroupInterface { func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Client) GroupInterface {
groupController := &GroupController{database: newGroupDatabase(db, rdb, mgoDB)} groupController := &GroupController{database: newGroupDatabase(db, rdb, mgoDB)}
return groupController return groupController
} }
@ -51,25 +52,40 @@ func (g *GroupController) GetSuperGroupByID(ctx context.Context, groupID string)
return g.database.GetSuperGroupByID(ctx, groupID) return g.database.GetSuperGroupByID(ctx, groupID)
} }
func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string, memberNumCount int) error {
return g.database.CreateSuperGroup(ctx, groupID, initMemberIDList, memberNumCount)
}
type DataBase interface { type DataBase interface {
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error)
CreateGroup(ctx context.Context, groups []*relation.Group) error CreateGroup(ctx context.Context, groups []*relation.Group) error
DeleteGroupByIDs(ctx context.Context, groupIDs []string) error DeleteGroupByIDs(ctx context.Context, groupIDs []string) error
TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error)
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error)
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string, memberNumCount int) error
} }
type GroupDataBase struct { type GroupDataBase struct {
sqlDB *relation.Group groupDB *relation.Group
groupMemberDB *relation.GroupMember
groupRequestDB *relation.GroupRequest
db *gorm.DB
cache *cache.GroupCache cache *cache.GroupCache
mongoDB *unrelation.SuperGroupMgoDB mongoDB *unrelation.SuperGroupMgoDB
} }
func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Database) DataBase { func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Client) DataBase {
sqlDB := relation.NewGroupDB(db) groupDB := relation.NewGroupDB(db)
groupMemberDB := relation.NewGroupMemberDB(db)
groupRequestDB := relation.NewGroupRequest(db)
newDB := db
database := &GroupDataBase{ database := &GroupDataBase{
sqlDB: sqlDB, groupDB: groupDB,
cache: cache.NewGroupCache(rdb, sqlDB, rockscache.Options{ groupMemberDB: groupMemberDB,
groupRequestDB: groupRequestDB,
db: newDB,
cache: cache.NewGroupCache(rdb, groupDB, groupMemberDB, groupRequestDB, rockscache.Options{
RandomExpireAdjustment: 0.2, RandomExpireAdjustment: 0.2,
DisableCacheRead: false, DisableCacheRead: false,
DisableCacheDelete: false, DisableCacheDelete: false,
@ -81,19 +97,19 @@ func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Datab
} }
func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) { func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
return g.cache.GetGroupsInfoFromCache(ctx, groupIDs) return g.cache.GetGroupsInfo(ctx, groupIDs)
} }
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation.Group) error { func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation.Group) error {
return g.sqlDB.Create(ctx, groups) return g.groupDB.Create(ctx, groups)
} }
func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string) error { func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string) error {
return g.sqlDB.DB.Transaction(func(tx *gorm.DB) error { return g.groupDB.DB.Transaction(func(tx *gorm.DB) error {
if err := g.sqlDB.Delete(ctx, groupIDs, tx); err != nil { if err := g.groupDB.Delete(ctx, groupIDs, tx); err != nil {
return err return err
} }
if err := g.cache.DelGroupsInfoFromCache(ctx, groupIDs); err != nil { if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil {
return err return err
} }
return nil return nil
@ -101,25 +117,56 @@ func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string)
} }
func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) { func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) {
return g.cache.GetGroupInfoFromCache(ctx, groupID) return g.cache.GetGroupInfo(ctx, groupID)
} }
func (g *GroupDataBase) Update(ctx context.Context, groups []*relation.Group) error { func (g *GroupDataBase) Update(ctx context.Context, groups []*relation.Group) error {
return g.sqlDB.DB.Transaction(func(tx *gorm.DB) error { return g.db.Transaction(func(tx *gorm.DB) error {
if err := g.sqlDB.Update(ctx, groups, tx); err != nil { if err := g.groupDB.Update(ctx, groups, tx); err != nil {
return err return err
} }
var groupIDs []string var groupIDs []string
for _, group := range groups { for _, group := range groups {
groupIDs = append(groupIDs, group.GroupID) groupIDs = append(groupIDs, group.GroupID)
} }
if err := g.cache.DelGroupsInfoFromCache(ctx, groupIDs); err != nil { if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil {
return err return err
} }
return nil return nil
}) })
} }
func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string, memberNumCount int) error {
sess, err := g.mongoDB.MgoClient.StartSession()
if err != nil {
return err
}
defer sess.EndSession(ctx)
sCtx := mongo.NewSessionContext(ctx, sess)
if err = g.mongoDB.CreateSuperGroup(sCtx, groupID, initMemberIDList, memberNumCount); err != nil {
_ = sess.AbortTransaction(ctx)
return err
}
if err = g.cache.DelJoinedSuperGroupIDs(ctx, initMemberIDList); err != nil {
_ = sess.AbortTransaction(ctx)
return err
}
return sess.CommitTransaction(ctx)
}
func (g *GroupDataBase) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) { func (g *GroupDataBase) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) {
return g.mongoDB.GetSuperGroup(ctx, groupID) return g.mongoDB.GetSuperGroup(ctx, groupID)
} }
func (g *GroupDataBase) CreateGroupAndMember(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error {
return g.db.Transaction(func(tx *gorm.DB) error {
if err := g.groupDB.Create(ctx, groups, tx); err != nil {
return err
}
if err := g.groupMemberDB.Create(ctx, groupMember, tx); err != nil {
return err
}
return nil
})
}

View File

@ -14,8 +14,6 @@ import (
"time" "time"
) )
var ChatLogDB *gorm.DB
type ChatLog struct { type ChatLog struct {
ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"` ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"`
ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"` ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"`
@ -32,6 +30,7 @@ type ChatLog struct {
SendTime time.Time `gorm:"column:send_time;index:sendTime;index:content_type,priority:1;index:session_type,priority:1;index:recv_id,priority:1;index:send_id,priority:1" json:"sendTime"` SendTime time.Time `gorm:"column:send_time;index:sendTime;index:content_type,priority:1;index:session_type,priority:1;index:recv_id,priority:1;index:send_id,priority:1" json:"sendTime"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"` CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"` Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
DB *gorm.DB
} }
func (ChatLog) TableName() string { func (ChatLog) TableName() string {

View File

@ -24,36 +24,40 @@ type GroupMember struct {
OperatorUserID string `gorm:"column:operator_user_id;size:64"` OperatorUserID string `gorm:"column:operator_user_id;size:64"`
MuteEndTime time.Time `gorm:"column:mute_end_time"` MuteEndTime time.Time `gorm:"column:mute_end_time"`
Ex string `gorm:"column:ex;size:1024"` Ex string `gorm:"column:ex;size:1024"`
DB *gorm.DB DB *gorm.DB `gorm:"-" json:"-"`
} }
func (g *GroupMember) Create(ctx context.Context, groupMemberList []*GroupMember) (err error) { func NewGroupMemberDB(db *gorm.DB) *GroupMember {
return &GroupMember{DB: db}
}
func (g *GroupMember) Create(ctx context.Context, groupMemberList []*GroupMember, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList)
}() }()
return utils.Wrap(GroupMemberDB.Create(&groupMemberList).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Create(&groupMemberList).Error, "")
} }
func (g *GroupMember) Delete(ctx context.Context, groupMembers []*GroupMember) (err error) { func (g *GroupMember) Delete(ctx context.Context, groupMembers []*GroupMember, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers)
}() }()
return utils.Wrap(GroupMemberDB.Delete(groupMembers).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "")
} }
func (g *GroupMember) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}) (err error) { func (g *GroupMember) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args)
}() }()
return utils.Wrap(GroupMemberDB.Model(&GroupMember{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Model(&GroupMember{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "")
} }
func (g *GroupMember) Update(ctx context.Context, groupMembers []*GroupMember) (err error) { func (g *GroupMember) Update(ctx context.Context, groupMembers []*GroupMember, tx ...*gorm.DB) (err error) {
defer func() { trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }() defer func() { trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }()
return utils.Wrap(GroupMemberDB.Updates(&groupMembers).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupMembers).Error, "")
} }
func (g *GroupMember) Find(ctx context.Context, groupMembers []*GroupMember) (groupList []*GroupMember, err error) { func (g *GroupMember) Find(ctx context.Context, groupMembers []*GroupMember, tx ...*gorm.DB) (groupList []*GroupMember, err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers, "groupList", groupList) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers, "groupList", groupList)
}() }()
@ -61,25 +65,23 @@ func (g *GroupMember) Find(ctx context.Context, groupMembers []*GroupMember) (gr
for _, groupMember := range groupMembers { for _, groupMember := range groupMembers {
where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID}) where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID})
} }
err = utils.Wrap(GroupMemberDB.Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "") return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "")
return groupList, err
} }
func (g *GroupMember) Take(ctx context.Context, groupID string, userID string) (groupMember *GroupMember, err error) { func (g *GroupMember) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupMember *GroupMember, err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
}() }()
groupMember = &GroupMember{} groupMember = &GroupMember{}
return groupMember, utils.Wrap(GroupMemberDB.Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "") return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "")
} }
func (g *GroupMember) TakeOwnerInfo(ctx context.Context, groupID string) (groupMember *GroupMember, err error) { func (g *GroupMember) TakeOwnerInfo(ctx context.Context, groupID string, tx ...*gorm.DB) (groupMember *GroupMember, err error) {
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember)
}() }()
groupMember = &GroupMember{} groupMember = &GroupMember{}
err = GroupMemberDB.Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
return groupMember, utils.Wrap(err, "")
} }
func InsertIntoGroupMember(toInsertInfo GroupMember) error { func InsertIntoGroupMember(toInsertInfo GroupMember) error {

View File

@ -37,8 +37,7 @@ func (g *Group) Create(ctx context.Context, groups []*Group, tx ...*gorm.DB) (er
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
}() }()
err = utils.Wrap(getDBConn(g.DB, tx).Create(&groups).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Create(&groups).Error, "")
return err
} }
func (g *Group) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) { func (g *Group) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) {
@ -66,8 +65,7 @@ func (g *Group) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (gr
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups)
}() }()
err = utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "") return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "")
return groups, err
} }
func (g *Group) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *Group, err error) { func (g *Group) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *Group, err error) {
@ -75,8 +73,7 @@ func (g *Group) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group
defer func() { defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group) trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
}() }()
err = utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "") return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "")
return group, err
} }
//func (g *Group) DeleteTx(ctx context.Context, groupIDs []string) error { //func (g *Group) DeleteTx(ctx context.Context, groupIDs []string) error {

View File

@ -22,6 +22,13 @@ type GroupRequest struct {
JoinSource int32 `gorm:"column:join_source"` JoinSource int32 `gorm:"column:join_source"`
InviterUserID string `gorm:"column:inviter_user_id;size:64"` InviterUserID string `gorm:"column:inviter_user_id;size:64"`
Ex string `gorm:"column:ex;size:1024"` Ex string `gorm:"column:ex;size:1024"`
DB *gorm.DB
}
func NewGroupRequest(db *gorm.DB) *GroupRequest {
return &GroupRequest{
DB: db,
}
} }
func (GroupRequest) TableName() string { func (GroupRequest) TableName() string {

View File

@ -2,61 +2,73 @@ package relation
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"gorm.io/gorm"
"time" "time"
) )
func GetActiveUserNum(from, to time.Time) (int32, error) { type Statistics struct {
var num int64 DB *gorm.DB
err := ChatLogDB.Table("chat_logs").Select("count(distinct(send_id))").Where("send_time >= ? and send_time <= ?", from, to).Count(&num).Error
return int32(num), err
} }
func GetIncreaseUserNum(from, to time.Time) (int32, error) { func NewStatistics(db *gorm.DB) *Statistics {
var num int64 return &Statistics{DB: db}
err := UserDB.Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error
return int32(num), err
} }
func GetTotalUserNum() (int32, error) { func (s *Statistics) getUserModel() *gorm.DB {
var num int64 return s.DB.Model(&User{})
err := UserDB.Count(&num).Error
return int32(num), err
} }
func GetTotalUserNumByDate(to time.Time) (int32, error) { func (s *Statistics) getChatLogModel() *gorm.DB {
var num int64 return s.DB.Model(&ChatLog{})
err := UserDB.Where("create_time <= ?", to).Count(&num).Error
return int32(num), err
} }
func GetPrivateMessageNum(from, to time.Time) (int32, error) { func (s *Statistics) getGroupModel() *gorm.DB {
var num int64 return s.DB.Model(&Group{})
err := ChatLogDB.Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, 1).Count(&num).Error
return int32(num), err
} }
func GetGroupMessageNum(from, to time.Time) (int32, error) { func (s *Statistics) GetActiveUserNum(from, to time.Time) (num int64, err error) {
var num int64 err = s.getChatLogModel().Select("count(distinct(send_id))").Where("send_time >= ? and send_time <= ?", from, to).Count(&num).Error
err := ChatLogDB.Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, 2).Count(&num).Error return num, err
return int32(num), err
} }
func GetIncreaseGroupNum(from, to time.Time) (int32, error) { func (s *Statistics) GetIncreaseUserNum(from, to time.Time) (num int64, err error) {
var num int64 err = s.getUserModel().Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error
err := GroupDB.Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error return num, err
return int32(num), err
} }
func GetTotalGroupNum() (int32, error) { func (s *Statistics) GetTotalUserNum() (num int64, err error) {
var num int64 err = s.getUserModel().Count(&num).Error
err := GroupDB.Count(&num).Error return num, err
return int32(num), err
} }
func GetGroupNum(to time.Time) (int32, error) { func (s *Statistics) GetTotalUserNumByDate(to time.Time) (num int64, err error) {
var num int64 err = s.getUserModel().Where("create_time <= ?", to).Count(&num).Error
err := GroupDB.Where("create_time <= ?", to).Count(&num).Error return num, err
return int32(num), err }
func (s *Statistics) GetPrivateMessageNum(from, to time.Time) (num int64, err error) {
err = s.getChatLogModel().Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, constant.SingleChatType).Count(&num).Error
return num, err
}
func (s *Statistics) GetGroupMessageNum(from, to time.Time) (num int64, err error) {
err = s.getChatLogModel().Where("send_time >= ? and send_time <= ? and session_type in (?)", from, to, []int{constant.GroupChatType, constant.SuperGroupChatType}).Count(&num).Error
return num, err
}
func (s *Statistics) GetIncreaseGroupNum(from, to time.Time) (num int64, err error) {
err = s.getGroupModel().Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error
return num, err
}
func (s *Statistics) GetTotalGroupNum() (num int64, err error) {
err = s.getGroupModel().Count(&num).Error
return num, err
}
func (s *Statistics) GetGroupNum(to time.Time) (num int64, err error) {
err = s.getGroupModel().Where("create_time <= ?", to).Count(&num).Error
return num, err
} }
type activeGroup struct { type activeGroup struct {
@ -65,14 +77,14 @@ type activeGroup struct {
MessageNum int `gorm:"column:message_num"` MessageNum int `gorm:"column:message_num"`
} }
func GetActiveGroups(from, to time.Time, limit int) ([]*activeGroup, error) { func (s *Statistics) GetActiveGroups(from, to time.Time, limit int) ([]*activeGroup, error) {
var activeGroups []*activeGroup var activeGroups []*activeGroup
err := ChatLogDB.Select("recv_id, count(*) as message_num").Where("send_time >= ? and send_time <= ? and session_type in (?)", from, to, []int{constant.GroupChatType, constant.SuperGroupChatType}).Group("recv_id").Limit(limit).Order("message_num DESC").Find(&activeGroups).Error err := s.getChatLogModel().Select("recv_id, count(*) as message_num").Where("send_time >= ? and send_time <= ? and session_type in (?)", from, to, []int{constant.GroupChatType, constant.SuperGroupChatType}).Group("recv_id").Limit(limit).Order("message_num DESC").Find(&activeGroups).Error
for _, activeGroup := range activeGroups { for _, activeGroup := range activeGroups {
group := Group{ group := Group{
GroupID: activeGroup.Id, GroupID: activeGroup.Id,
} }
GroupDB.Where("group_id= ? ", group.GroupID).Find(&group) s.getGroupModel().Where("group_id= ? ", group.GroupID).Find(&group)
activeGroup.Name = group.GroupName activeGroup.Name = group.GroupName
} }
return activeGroups, err return activeGroups, err
@ -84,16 +96,15 @@ type activeUser struct {
MessageNum int `gorm:"column:message_num"` MessageNum int `gorm:"column:message_num"`
} }
func GetActiveUsers(from, to time.Time, limit int) ([]*activeUser, error) { func (s *Statistics) GetActiveUsers(from, to time.Time, limit int) (activeUsers []*activeUser, err error) {
var activeUsers []*activeUser err = s.getChatLogModel().Select("send_id, count(*) as message_num").Where("send_time >= ? and send_time <= ? and session_type in (?)", from, to, []int{constant.SingleChatType, constant.GroupChatType, constant.SuperGroupChatType}).Group("send_id").Limit(limit).Order("message_num DESC").Find(&activeUsers).Error
err := ChatLogDB.Select("send_id, count(*) as message_num").Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, constant.SingleChatType).Group("send_id").Limit(limit).Order("message_num DESC").Find(&activeUsers).Error
for _, activeUser := range activeUsers { for _, activeUser := range activeUsers {
user := User{ user := User{
UserID: activeUser.ID, UserID: activeUser.ID,
} }
err = UserDB.Select("user_id, name").Find(&user).Error err = s.getUserModel().Select("user_id, name").Find(&user).Error
if err != nil { if err != nil {
continue return nil, err
} }
activeUser.Name = user.Nickname activeUser.Name = user.Nickname
activeUser.ID = user.UserID activeUser.ID = user.UserID

View File

@ -9,11 +9,6 @@ import (
"time" "time"
) )
var (
BlackListDB *gorm.DB
UserDB *gorm.DB
)
func InitManager() { func InitManager() {
for k, v := range config.Config.Manager.AppManagerUid { for k, v := range config.Config.Manager.AppManagerUid {
_, err := GetUserByUserID(v) _, err := GetUserByUserID(v)

View File

@ -8,13 +8,12 @@ import (
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/x/bsonx" "go.mongodb.org/mongo-driver/x/bsonx"
"log"
"strings" "strings"
"time" "time"
) )
type Mongo struct { type Mongo struct {
DB *mongo.Database DB *mongo.Client
} }
func (m *Mongo) InitMongo() { func (m *Mongo) InitMongo() {
@ -45,7 +44,7 @@ func (m *Mongo) InitMongo() {
config.Config.Mongo.DBMaxPoolSize) config.Config.Mongo.DBMaxPoolSize)
} }
} }
log.Println(utils.GetFuncName(1), "start to init mongoDB:", uri) fmt.Println(utils.GetFuncName(1), "start to init mongoDB:", uri)
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err != nil { if err != nil {
time.Sleep(time.Duration(30) * time.Second) time.Sleep(time.Duration(30) * time.Second)
@ -54,7 +53,11 @@ func (m *Mongo) InitMongo() {
panic(err.Error() + " mongo.Connect failed " + uri) panic(err.Error() + " mongo.Connect failed " + uri)
} }
} }
m.DB = mongoClient.Database(config.Config.Mongo.DBDatabase) m.DB = mongoClient
}
func (m *Mongo) GetClient() *mongo.Client {
return m.DB
} }
func (m *Mongo) CreateTagIndex() { func (m *Mongo) CreateTagIndex() {
@ -97,7 +100,7 @@ func (m *Mongo) CreateWorkMomentIndex() {
} }
func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...string) error { func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...string) error {
db := m.DB.Collection(collection) db := m.DB.Database(config.Config.Mongo.DBDatabase).Collection(collection)
opts := options.CreateIndexes().SetMaxTime(10 * time.Second) opts := options.CreateIndexes().SetMaxTime(10 * time.Second)
indexView := db.Indexes() indexView := db.Indexes()
keysDoc := bsonx.Doc{} keysDoc := bsonx.Doc{}

View File

@ -1,6 +1,7 @@
package unrelation package unrelation
import ( import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
@ -15,7 +16,8 @@ const (
) )
type SuperGroupMgoDB struct { type SuperGroupMgoDB struct {
mgoDB *mongo.Database MgoClient *mongo.Client
MgoDB *mongo.Database
superGroupCollection *mongo.Collection superGroupCollection *mongo.Collection
userToSuperGroupCollection *mongo.Collection userToSuperGroupCollection *mongo.Collection
} }
@ -30,41 +32,32 @@ type UserToSuperGroup struct {
GroupIDList []string `bson:"group_id_list" json:"groupIDList"` GroupIDList []string `bson:"group_id_list" json:"groupIDList"`
} }
func NewSuperGroupMgoDB(mgoDB *mongo.Database) *SuperGroupMgoDB { func NewSuperGroupMgoDB(mgoClient *mongo.Client) *SuperGroupMgoDB {
return &SuperGroupMgoDB{mgoDB: mgoDB, superGroupCollection: mgoDB.Collection(cSuperGroup), userToSuperGroupCollection: mgoDB.Collection(cUserToSuperGroup)} mgoDB := mgoClient.Database(config.Config.Mongo.DBDatabase)
return &SuperGroupMgoDB{MgoDB: mgoDB, MgoClient: mgoClient, superGroupCollection: mgoDB.Collection(cSuperGroup), userToSuperGroupCollection: mgoDB.Collection(cUserToSuperGroup)}
} }
func (db *SuperGroupMgoDB) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string, memberNumCount int) error { func (db *SuperGroupMgoDB) CreateSuperGroup(sCtx mongo.SessionContext, groupID string, initMemberIDList []string, memberNumCount int) error {
//ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) superGroup := SuperGroup{
//c := db.mgoDB.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup) GroupID: groupID,
opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) MemberIDList: initMemberIDList,
return db.mgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { }
err := sCtx.StartTransaction() _, err := db.superGroupCollection.InsertOne(sCtx, superGroup)
if err != nil {
return err
}
upsert := true
opts := &options.UpdateOptions{
Upsert: &upsert,
}
for _, userID := range initMemberIDList {
_, err = db.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
if err != nil { if err != nil {
return err return err
} }
superGroup := SuperGroup{ }
GroupID: groupID, return nil
MemberIDList: initMemberIDList,
}
_, err = db.superGroupCollection.InsertOne(sCtx, superGroup)
if err != nil {
_ = sCtx.AbortTransaction(ctx)
return err
}
upsert := true
opts := &options.UpdateOptions{
Upsert: &upsert,
}
for _, userID := range initMemberIDList {
_, err = db.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
if err != nil {
_ = sCtx.AbortTransaction(ctx)
return err
}
}
return sCtx.CommitTransaction(ctx)
})
} }
func (db *SuperGroupMgoDB) GetSuperGroup(ctx context.Context, groupID string) (*SuperGroup, error) { func (db *SuperGroupMgoDB) GetSuperGroup(ctx context.Context, groupID string) (*SuperGroup, error) {
@ -75,7 +68,7 @@ func (db *SuperGroupMgoDB) GetSuperGroup(ctx context.Context, groupID string) (*
func (db *SuperGroupMgoDB) AddUserToSuperGroup(ctx context.Context, groupID string, userIDList []string) error { func (db *SuperGroupMgoDB) AddUserToSuperGroup(ctx context.Context, groupID string, userIDList []string) error {
opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) opts := options.Session().SetDefaultReadConcern(readconcern.Majority())
return db.mgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { return db.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error {
_, err := db.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDList}}}) _, err := db.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDList}}})
if err != nil { if err != nil {
_ = sCtx.AbortTransaction(ctx) _ = sCtx.AbortTransaction(ctx)
@ -98,7 +91,7 @@ func (db *SuperGroupMgoDB) AddUserToSuperGroup(ctx context.Context, groupID stri
func (db *SuperGroupMgoDB) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDList []string) error { func (db *SuperGroupMgoDB) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDList []string) error {
opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) opts := options.Session().SetDefaultReadConcern(readconcern.Majority())
return db.mgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { return db.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error {
_, err := db.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDList}}}) _, err := db.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDList}}})
if err != nil { if err != nil {
_ = sCtx.AbortTransaction(ctx) _ = sCtx.AbortTransaction(ctx)
@ -121,7 +114,7 @@ func (db *SuperGroupMgoDB) GetSuperGroupByUserID(ctx context.Context, userID str
func (db *SuperGroupMgoDB) DeleteSuperGroup(ctx context.Context, groupID string) error { func (db *SuperGroupMgoDB) DeleteSuperGroup(ctx context.Context, groupID string) error {
opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) opts := options.Session().SetDefaultReadConcern(readconcern.Majority())
return db.mgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { return db.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error {
superGroup := &SuperGroup{} superGroup := &SuperGroup{}
_, err := db.superGroupCollection.DeleteOne(sCtx, bson.M{"group_id": groupID}) _, err := db.superGroupCollection.DeleteOne(sCtx, bson.M{"group_id": groupID})
if err != nil { if err != nil {

View File

@ -3,24 +3,15 @@ option go_package = "Open_IM/pkg/proto/admin_cms;admin_cms";
import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto"; import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto";
package admin_cms; package admin_cms;
message CommonResp {
int32 errCode = 1;
string errMsg = 2;
}
message AdminLoginReq { message AdminLoginReq {
string operationID = 1;
string adminID = 2; string adminID = 2;
string secret = 3; string secret = 3;
} }
message AdminLoginResp { message AdminLoginResp {
string token = 1; string token = 1;
string userName = 2; string userName = 2;
string faceURL = 3; string faceURL = 3;
CommonResp commonResp = 4;
} }
message GetUserTokenReq { message GetUserTokenReq {

View File

@ -1,853 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: cache/cache.proto
package cache // import "Open_IM/pkg/proto/cache"
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import sdk_ws "Open_IM/pkg/proto/sdk_ws"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
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:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_e3bd73ca9c307fc2, []int{0}
}
func (m *GetFriendIDListFromCacheReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetFriendIDListFromCacheReq.Unmarshal(m, b)
}
func (m *GetFriendIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetFriendIDListFromCacheReq.Marshal(b, m, deterministic)
}
func (dst *GetFriendIDListFromCacheReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetFriendIDListFromCacheReq.Merge(dst, src)
}
func (m *GetFriendIDListFromCacheReq) XXX_Size() int {
return xxx_messageInfo_GetFriendIDListFromCacheReq.Size(m)
}
func (m *GetFriendIDListFromCacheReq) XXX_DiscardUnknown() {
xxx_messageInfo_GetFriendIDListFromCacheReq.DiscardUnknown(m)
}
var xxx_messageInfo_GetFriendIDListFromCacheReq proto.InternalMessageInfo
func (m *GetFriendIDListFromCacheReq) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *GetFriendIDListFromCacheReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type GetFriendIDListFromCacheResp struct {
UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"`
CommonResp *sdk_ws.CommonResp `protobuf:"bytes,2,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_e3bd73ca9c307fc2, []int{1}
}
func (m *GetFriendIDListFromCacheResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetFriendIDListFromCacheResp.Unmarshal(m, b)
}
func (m *GetFriendIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetFriendIDListFromCacheResp.Marshal(b, m, deterministic)
}
func (dst *GetFriendIDListFromCacheResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetFriendIDListFromCacheResp.Merge(dst, src)
}
func (m *GetFriendIDListFromCacheResp) XXX_Size() int {
return xxx_messageInfo_GetFriendIDListFromCacheResp.Size(m)
}
func (m *GetFriendIDListFromCacheResp) XXX_DiscardUnknown() {
xxx_messageInfo_GetFriendIDListFromCacheResp.DiscardUnknown(m)
}
var xxx_messageInfo_GetFriendIDListFromCacheResp proto.InternalMessageInfo
func (m *GetFriendIDListFromCacheResp) GetUserIDList() []string {
if m != nil {
return m.UserIDList
}
return nil
}
func (m *GetFriendIDListFromCacheResp) GetCommonResp() *sdk_ws.CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
type DelFriendIDListFromCacheReq 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:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DelFriendIDListFromCacheReq) Reset() { *m = DelFriendIDListFromCacheReq{} }
func (m *DelFriendIDListFromCacheReq) String() string { return proto.CompactTextString(m) }
func (*DelFriendIDListFromCacheReq) ProtoMessage() {}
func (*DelFriendIDListFromCacheReq) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{2}
}
func (m *DelFriendIDListFromCacheReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DelFriendIDListFromCacheReq.Unmarshal(m, b)
}
func (m *DelFriendIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DelFriendIDListFromCacheReq.Marshal(b, m, deterministic)
}
func (dst *DelFriendIDListFromCacheReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_DelFriendIDListFromCacheReq.Merge(dst, src)
}
func (m *DelFriendIDListFromCacheReq) XXX_Size() int {
return xxx_messageInfo_DelFriendIDListFromCacheReq.Size(m)
}
func (m *DelFriendIDListFromCacheReq) XXX_DiscardUnknown() {
xxx_messageInfo_DelFriendIDListFromCacheReq.DiscardUnknown(m)
}
var xxx_messageInfo_DelFriendIDListFromCacheReq proto.InternalMessageInfo
func (m *DelFriendIDListFromCacheReq) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *DelFriendIDListFromCacheReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type DelFriendIDListFromCacheResp struct {
CommonResp *sdk_ws.CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DelFriendIDListFromCacheResp) Reset() { *m = DelFriendIDListFromCacheResp{} }
func (m *DelFriendIDListFromCacheResp) String() string { return proto.CompactTextString(m) }
func (*DelFriendIDListFromCacheResp) ProtoMessage() {}
func (*DelFriendIDListFromCacheResp) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{3}
}
func (m *DelFriendIDListFromCacheResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DelFriendIDListFromCacheResp.Unmarshal(m, b)
}
func (m *DelFriendIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DelFriendIDListFromCacheResp.Marshal(b, m, deterministic)
}
func (dst *DelFriendIDListFromCacheResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_DelFriendIDListFromCacheResp.Merge(dst, src)
}
func (m *DelFriendIDListFromCacheResp) XXX_Size() int {
return xxx_messageInfo_DelFriendIDListFromCacheResp.Size(m)
}
func (m *DelFriendIDListFromCacheResp) XXX_DiscardUnknown() {
xxx_messageInfo_DelFriendIDListFromCacheResp.DiscardUnknown(m)
}
var xxx_messageInfo_DelFriendIDListFromCacheResp proto.InternalMessageInfo
func (m *DelFriendIDListFromCacheResp) GetCommonResp() *sdk_ws.CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
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:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_e3bd73ca9c307fc2, []int{4}
}
func (m *GetBlackIDListFromCacheReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetBlackIDListFromCacheReq.Unmarshal(m, b)
}
func (m *GetBlackIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetBlackIDListFromCacheReq.Marshal(b, m, deterministic)
}
func (dst *GetBlackIDListFromCacheReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetBlackIDListFromCacheReq.Merge(dst, src)
}
func (m *GetBlackIDListFromCacheReq) XXX_Size() int {
return xxx_messageInfo_GetBlackIDListFromCacheReq.Size(m)
}
func (m *GetBlackIDListFromCacheReq) XXX_DiscardUnknown() {
xxx_messageInfo_GetBlackIDListFromCacheReq.DiscardUnknown(m)
}
var xxx_messageInfo_GetBlackIDListFromCacheReq proto.InternalMessageInfo
func (m *GetBlackIDListFromCacheReq) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *GetBlackIDListFromCacheReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type GetBlackIDListFromCacheResp struct {
UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"`
CommonResp *sdk_ws.CommonResp `protobuf:"bytes,2,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_e3bd73ca9c307fc2, []int{5}
}
func (m *GetBlackIDListFromCacheResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetBlackIDListFromCacheResp.Unmarshal(m, b)
}
func (m *GetBlackIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetBlackIDListFromCacheResp.Marshal(b, m, deterministic)
}
func (dst *GetBlackIDListFromCacheResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetBlackIDListFromCacheResp.Merge(dst, src)
}
func (m *GetBlackIDListFromCacheResp) XXX_Size() int {
return xxx_messageInfo_GetBlackIDListFromCacheResp.Size(m)
}
func (m *GetBlackIDListFromCacheResp) XXX_DiscardUnknown() {
xxx_messageInfo_GetBlackIDListFromCacheResp.DiscardUnknown(m)
}
var xxx_messageInfo_GetBlackIDListFromCacheResp proto.InternalMessageInfo
func (m *GetBlackIDListFromCacheResp) GetUserIDList() []string {
if m != nil {
return m.UserIDList
}
return nil
}
func (m *GetBlackIDListFromCacheResp) GetCommonResp() *sdk_ws.CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
type DelBlackIDListFromCacheReq 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:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DelBlackIDListFromCacheReq) Reset() { *m = DelBlackIDListFromCacheReq{} }
func (m *DelBlackIDListFromCacheReq) String() string { return proto.CompactTextString(m) }
func (*DelBlackIDListFromCacheReq) ProtoMessage() {}
func (*DelBlackIDListFromCacheReq) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{6}
}
func (m *DelBlackIDListFromCacheReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DelBlackIDListFromCacheReq.Unmarshal(m, b)
}
func (m *DelBlackIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DelBlackIDListFromCacheReq.Marshal(b, m, deterministic)
}
func (dst *DelBlackIDListFromCacheReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_DelBlackIDListFromCacheReq.Merge(dst, src)
}
func (m *DelBlackIDListFromCacheReq) XXX_Size() int {
return xxx_messageInfo_DelBlackIDListFromCacheReq.Size(m)
}
func (m *DelBlackIDListFromCacheReq) XXX_DiscardUnknown() {
xxx_messageInfo_DelBlackIDListFromCacheReq.DiscardUnknown(m)
}
var xxx_messageInfo_DelBlackIDListFromCacheReq proto.InternalMessageInfo
func (m *DelBlackIDListFromCacheReq) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *DelBlackIDListFromCacheReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type DelBlackIDListFromCacheResp struct {
CommonResp *sdk_ws.CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DelBlackIDListFromCacheResp) Reset() { *m = DelBlackIDListFromCacheResp{} }
func (m *DelBlackIDListFromCacheResp) String() string { return proto.CompactTextString(m) }
func (*DelBlackIDListFromCacheResp) ProtoMessage() {}
func (*DelBlackIDListFromCacheResp) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{7}
}
func (m *DelBlackIDListFromCacheResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DelBlackIDListFromCacheResp.Unmarshal(m, b)
}
func (m *DelBlackIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DelBlackIDListFromCacheResp.Marshal(b, m, deterministic)
}
func (dst *DelBlackIDListFromCacheResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_DelBlackIDListFromCacheResp.Merge(dst, src)
}
func (m *DelBlackIDListFromCacheResp) XXX_Size() int {
return xxx_messageInfo_DelBlackIDListFromCacheResp.Size(m)
}
func (m *DelBlackIDListFromCacheResp) XXX_DiscardUnknown() {
xxx_messageInfo_DelBlackIDListFromCacheResp.DiscardUnknown(m)
}
var xxx_messageInfo_DelBlackIDListFromCacheResp proto.InternalMessageInfo
func (m *DelBlackIDListFromCacheResp) GetCommonResp() *sdk_ws.CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
type GetGroupMemberIDListFromCacheReq struct {
OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"`
GroupID string `protobuf:"bytes,2,opt,name=groupID" json:"groupID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetGroupMemberIDListFromCacheReq) Reset() { *m = GetGroupMemberIDListFromCacheReq{} }
func (m *GetGroupMemberIDListFromCacheReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupMemberIDListFromCacheReq) ProtoMessage() {}
func (*GetGroupMemberIDListFromCacheReq) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{8}
}
func (m *GetGroupMemberIDListFromCacheReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMemberIDListFromCacheReq.Unmarshal(m, b)
}
func (m *GetGroupMemberIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetGroupMemberIDListFromCacheReq.Marshal(b, m, deterministic)
}
func (dst *GetGroupMemberIDListFromCacheReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetGroupMemberIDListFromCacheReq.Merge(dst, src)
}
func (m *GetGroupMemberIDListFromCacheReq) XXX_Size() int {
return xxx_messageInfo_GetGroupMemberIDListFromCacheReq.Size(m)
}
func (m *GetGroupMemberIDListFromCacheReq) XXX_DiscardUnknown() {
xxx_messageInfo_GetGroupMemberIDListFromCacheReq.DiscardUnknown(m)
}
var xxx_messageInfo_GetGroupMemberIDListFromCacheReq proto.InternalMessageInfo
func (m *GetGroupMemberIDListFromCacheReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
func (m *GetGroupMemberIDListFromCacheReq) GetGroupID() string {
if m != nil {
return m.GroupID
}
return ""
}
type GetGroupMemberIDListFromCacheResp struct {
CommonResp *sdk_ws.CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
UserIDList []string `protobuf:"bytes,2,rep,name=userIDList" json:"userIDList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetGroupMemberIDListFromCacheResp) Reset() { *m = GetGroupMemberIDListFromCacheResp{} }
func (m *GetGroupMemberIDListFromCacheResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupMemberIDListFromCacheResp) ProtoMessage() {}
func (*GetGroupMemberIDListFromCacheResp) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{9}
}
func (m *GetGroupMemberIDListFromCacheResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMemberIDListFromCacheResp.Unmarshal(m, b)
}
func (m *GetGroupMemberIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetGroupMemberIDListFromCacheResp.Marshal(b, m, deterministic)
}
func (dst *GetGroupMemberIDListFromCacheResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetGroupMemberIDListFromCacheResp.Merge(dst, src)
}
func (m *GetGroupMemberIDListFromCacheResp) XXX_Size() int {
return xxx_messageInfo_GetGroupMemberIDListFromCacheResp.Size(m)
}
func (m *GetGroupMemberIDListFromCacheResp) XXX_DiscardUnknown() {
xxx_messageInfo_GetGroupMemberIDListFromCacheResp.DiscardUnknown(m)
}
var xxx_messageInfo_GetGroupMemberIDListFromCacheResp proto.InternalMessageInfo
func (m *GetGroupMemberIDListFromCacheResp) GetCommonResp() *sdk_ws.CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
func (m *GetGroupMemberIDListFromCacheResp) GetUserIDList() []string {
if m != nil {
return m.UserIDList
}
return nil
}
type DelGroupMemberIDListFromCacheReq struct {
GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,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 *DelGroupMemberIDListFromCacheReq) Reset() { *m = DelGroupMemberIDListFromCacheReq{} }
func (m *DelGroupMemberIDListFromCacheReq) String() string { return proto.CompactTextString(m) }
func (*DelGroupMemberIDListFromCacheReq) ProtoMessage() {}
func (*DelGroupMemberIDListFromCacheReq) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{10}
}
func (m *DelGroupMemberIDListFromCacheReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DelGroupMemberIDListFromCacheReq.Unmarshal(m, b)
}
func (m *DelGroupMemberIDListFromCacheReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DelGroupMemberIDListFromCacheReq.Marshal(b, m, deterministic)
}
func (dst *DelGroupMemberIDListFromCacheReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_DelGroupMemberIDListFromCacheReq.Merge(dst, src)
}
func (m *DelGroupMemberIDListFromCacheReq) XXX_Size() int {
return xxx_messageInfo_DelGroupMemberIDListFromCacheReq.Size(m)
}
func (m *DelGroupMemberIDListFromCacheReq) XXX_DiscardUnknown() {
xxx_messageInfo_DelGroupMemberIDListFromCacheReq.DiscardUnknown(m)
}
var xxx_messageInfo_DelGroupMemberIDListFromCacheReq proto.InternalMessageInfo
func (m *DelGroupMemberIDListFromCacheReq) GetGroupID() string {
if m != nil {
return m.GroupID
}
return ""
}
func (m *DelGroupMemberIDListFromCacheReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type DelGroupMemberIDListFromCacheResp struct {
CommonResp *sdk_ws.CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DelGroupMemberIDListFromCacheResp) Reset() { *m = DelGroupMemberIDListFromCacheResp{} }
func (m *DelGroupMemberIDListFromCacheResp) String() string { return proto.CompactTextString(m) }
func (*DelGroupMemberIDListFromCacheResp) ProtoMessage() {}
func (*DelGroupMemberIDListFromCacheResp) Descriptor() ([]byte, []int) {
return fileDescriptor_cache_e3bd73ca9c307fc2, []int{11}
}
func (m *DelGroupMemberIDListFromCacheResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DelGroupMemberIDListFromCacheResp.Unmarshal(m, b)
}
func (m *DelGroupMemberIDListFromCacheResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DelGroupMemberIDListFromCacheResp.Marshal(b, m, deterministic)
}
func (dst *DelGroupMemberIDListFromCacheResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_DelGroupMemberIDListFromCacheResp.Merge(dst, src)
}
func (m *DelGroupMemberIDListFromCacheResp) XXX_Size() int {
return xxx_messageInfo_DelGroupMemberIDListFromCacheResp.Size(m)
}
func (m *DelGroupMemberIDListFromCacheResp) XXX_DiscardUnknown() {
xxx_messageInfo_DelGroupMemberIDListFromCacheResp.DiscardUnknown(m)
}
var xxx_messageInfo_DelGroupMemberIDListFromCacheResp proto.InternalMessageInfo
func (m *DelGroupMemberIDListFromCacheResp) GetCommonResp() *sdk_ws.CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
func init() {
proto.RegisterType((*GetFriendIDListFromCacheReq)(nil), "cache.GetFriendIDListFromCacheReq")
proto.RegisterType((*GetFriendIDListFromCacheResp)(nil), "cache.GetFriendIDListFromCacheResp")
proto.RegisterType((*DelFriendIDListFromCacheReq)(nil), "cache.DelFriendIDListFromCacheReq")
proto.RegisterType((*DelFriendIDListFromCacheResp)(nil), "cache.DelFriendIDListFromCacheResp")
proto.RegisterType((*GetBlackIDListFromCacheReq)(nil), "cache.GetBlackIDListFromCacheReq")
proto.RegisterType((*GetBlackIDListFromCacheResp)(nil), "cache.GetBlackIDListFromCacheResp")
proto.RegisterType((*DelBlackIDListFromCacheReq)(nil), "cache.DelBlackIDListFromCacheReq")
proto.RegisterType((*DelBlackIDListFromCacheResp)(nil), "cache.DelBlackIDListFromCacheResp")
proto.RegisterType((*GetGroupMemberIDListFromCacheReq)(nil), "cache.GetGroupMemberIDListFromCacheReq")
proto.RegisterType((*GetGroupMemberIDListFromCacheResp)(nil), "cache.GetGroupMemberIDListFromCacheResp")
proto.RegisterType((*DelGroupMemberIDListFromCacheReq)(nil), "cache.DelGroupMemberIDListFromCacheReq")
proto.RegisterType((*DelGroupMemberIDListFromCacheResp)(nil), "cache.DelGroupMemberIDListFromCacheResp")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for Cache service
type CacheClient interface {
// friendInfo
GetFriendIDListFromCache(ctx context.Context, in *GetFriendIDListFromCacheReq, opts ...grpc.CallOption) (*GetFriendIDListFromCacheResp, error)
// for dtm
DelFriendIDListFromCache(ctx context.Context, in *DelFriendIDListFromCacheReq, opts ...grpc.CallOption) (*DelFriendIDListFromCacheResp, error)
// blackList
GetBlackIDListFromCache(ctx context.Context, in *GetBlackIDListFromCacheReq, opts ...grpc.CallOption) (*GetBlackIDListFromCacheResp, error)
// for dtm
DelBlackIDListFromCache(ctx context.Context, in *DelBlackIDListFromCacheReq, opts ...grpc.CallOption) (*DelBlackIDListFromCacheResp, error)
// group
GetGroupMemberIDListFromCache(ctx context.Context, in *GetGroupMemberIDListFromCacheReq, opts ...grpc.CallOption) (*GetGroupMemberIDListFromCacheResp, error)
// for dtm
DelGroupMemberIDListFromCache(ctx context.Context, in *DelGroupMemberIDListFromCacheReq, opts ...grpc.CallOption) (*DelGroupMemberIDListFromCacheResp, error)
}
type cacheClient struct {
cc *grpc.ClientConn
}
func NewCacheClient(cc *grpc.ClientConn) CacheClient {
return &cacheClient{cc}
}
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) DelFriendIDListFromCache(ctx context.Context, in *DelFriendIDListFromCacheReq, opts ...grpc.CallOption) (*DelFriendIDListFromCacheResp, error) {
out := new(DelFriendIDListFromCacheResp)
err := grpc.Invoke(ctx, "/cache.cache/DelFriendIDListFromCache", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
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) DelBlackIDListFromCache(ctx context.Context, in *DelBlackIDListFromCacheReq, opts ...grpc.CallOption) (*DelBlackIDListFromCacheResp, error) {
out := new(DelBlackIDListFromCacheResp)
err := grpc.Invoke(ctx, "/cache.cache/DelBlackIDListFromCache", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *cacheClient) GetGroupMemberIDListFromCache(ctx context.Context, in *GetGroupMemberIDListFromCacheReq, opts ...grpc.CallOption) (*GetGroupMemberIDListFromCacheResp, error) {
out := new(GetGroupMemberIDListFromCacheResp)
err := grpc.Invoke(ctx, "/cache.cache/GetGroupMemberIDListFromCache", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *cacheClient) DelGroupMemberIDListFromCache(ctx context.Context, in *DelGroupMemberIDListFromCacheReq, opts ...grpc.CallOption) (*DelGroupMemberIDListFromCacheResp, error) {
out := new(DelGroupMemberIDListFromCacheResp)
err := grpc.Invoke(ctx, "/cache.cache/DelGroupMemberIDListFromCache", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Cache service
type CacheServer interface {
// friendInfo
GetFriendIDListFromCache(context.Context, *GetFriendIDListFromCacheReq) (*GetFriendIDListFromCacheResp, error)
// for dtm
DelFriendIDListFromCache(context.Context, *DelFriendIDListFromCacheReq) (*DelFriendIDListFromCacheResp, error)
// blackList
GetBlackIDListFromCache(context.Context, *GetBlackIDListFromCacheReq) (*GetBlackIDListFromCacheResp, error)
// for dtm
DelBlackIDListFromCache(context.Context, *DelBlackIDListFromCacheReq) (*DelBlackIDListFromCacheResp, error)
// group
GetGroupMemberIDListFromCache(context.Context, *GetGroupMemberIDListFromCacheReq) (*GetGroupMemberIDListFromCacheResp, error)
// for dtm
DelGroupMemberIDListFromCache(context.Context, *DelGroupMemberIDListFromCacheReq) (*DelGroupMemberIDListFromCacheResp, error)
}
func RegisterCacheServer(s *grpc.Server, srv CacheServer) {
s.RegisterService(&_Cache_serviceDesc, srv)
}
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).GetFriendIDListFromCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cache.cache/GetFriendIDListFromCache",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CacheServer).GetFriendIDListFromCache(ctx, req.(*GetFriendIDListFromCacheReq))
}
return interceptor(ctx, in, info, handler)
}
func _Cache_DelFriendIDListFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DelFriendIDListFromCacheReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CacheServer).DelFriendIDListFromCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cache.cache/DelFriendIDListFromCache",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CacheServer).DelFriendIDListFromCache(ctx, req.(*DelFriendIDListFromCacheReq))
}
return interceptor(ctx, in, info, handler)
}
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).GetBlackIDListFromCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cache.cache/GetBlackIDListFromCache",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CacheServer).GetBlackIDListFromCache(ctx, req.(*GetBlackIDListFromCacheReq))
}
return interceptor(ctx, in, info, handler)
}
func _Cache_DelBlackIDListFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DelBlackIDListFromCacheReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CacheServer).DelBlackIDListFromCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cache.cache/DelBlackIDListFromCache",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CacheServer).DelBlackIDListFromCache(ctx, req.(*DelBlackIDListFromCacheReq))
}
return interceptor(ctx, in, info, handler)
}
func _Cache_GetGroupMemberIDListFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetGroupMemberIDListFromCacheReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CacheServer).GetGroupMemberIDListFromCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cache.cache/GetGroupMemberIDListFromCache",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CacheServer).GetGroupMemberIDListFromCache(ctx, req.(*GetGroupMemberIDListFromCacheReq))
}
return interceptor(ctx, in, info, handler)
}
func _Cache_DelGroupMemberIDListFromCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DelGroupMemberIDListFromCacheReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CacheServer).DelGroupMemberIDListFromCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cache.cache/DelGroupMemberIDListFromCache",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CacheServer).DelGroupMemberIDListFromCache(ctx, req.(*DelGroupMemberIDListFromCacheReq))
}
return interceptor(ctx, in, info, handler)
}
var _Cache_serviceDesc = grpc.ServiceDesc{
ServiceName: "cache.cache",
HandlerType: (*CacheServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetFriendIDListFromCache",
Handler: _Cache_GetFriendIDListFromCache_Handler,
},
{
MethodName: "DelFriendIDListFromCache",
Handler: _Cache_DelFriendIDListFromCache_Handler,
},
{
MethodName: "GetBlackIDListFromCache",
Handler: _Cache_GetBlackIDListFromCache_Handler,
},
{
MethodName: "DelBlackIDListFromCache",
Handler: _Cache_DelBlackIDListFromCache_Handler,
},
{
MethodName: "GetGroupMemberIDListFromCache",
Handler: _Cache_GetGroupMemberIDListFromCache_Handler,
},
{
MethodName: "DelGroupMemberIDListFromCache",
Handler: _Cache_DelGroupMemberIDListFromCache_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cache/cache.proto",
}
func init() { proto.RegisterFile("cache/cache.proto", fileDescriptor_cache_e3bd73ca9c307fc2) }
var fileDescriptor_cache_e3bd73ca9c307fc2 = []byte{
// 466 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x8f, 0x93, 0x40,
0x14, 0x0e, 0xab, 0xae, 0xd9, 0xb7, 0x27, 0xe7, 0xa0, 0x04, 0xb7, 0x4a, 0xf1, 0x20, 0x97, 0x85,
0x64, 0x3d, 0x1a, 0x2f, 0x5b, 0x52, 0x42, 0x62, 0x63, 0x82, 0x49, 0x4d, 0x8c, 0x8a, 0x94, 0x4e,
0x2a, 0x29, 0x30, 0xe3, 0x0c, 0xb5, 0x17, 0xbd, 0xf8, 0xbf, 0x4d, 0xcc, 0x0c, 0x96, 0x52, 0x74,
0xa0, 0xa6, 0xed, 0x85, 0x64, 0x66, 0xde, 0xbc, 0xef, 0xfb, 0x78, 0xef, 0x7d, 0x03, 0x0f, 0x92,
0x38, 0xf9, 0x82, 0x5d, 0xf9, 0x75, 0x28, 0x23, 0x25, 0x41, 0xf7, 0xe4, 0xc2, 0xb0, 0xdf, 0x50,
0x5c, 0x5c, 0x07, 0x93, 0xeb, 0xb7, 0x98, 0x7d, 0xc3, 0xcc, 0xa5, 0xcb, 0x85, 0x2b, 0x03, 0x5c,
0x3e, 0x5f, 0x46, 0x6b, 0xee, 0xae, 0x79, 0x75, 0xc1, 0x7a, 0x07, 0x8f, 0x7d, 0x5c, 0x8e, 0x59,
0x8a, 0x8b, 0x79, 0xe0, 0xbd, 0x4e, 0x79, 0x39, 0x66, 0x24, 0x1f, 0x89, 0x2c, 0x21, 0xfe, 0x8a,
0x1e, 0xc2, 0xf9, 0x8a, 0x63, 0x16, 0x78, 0xba, 0x66, 0x6a, 0xf6, 0x45, 0xf8, 0x67, 0x85, 0x4c,
0xb8, 0x24, 0x14, 0xb3, 0xb8, 0x4c, 0x49, 0x11, 0x78, 0xfa, 0x99, 0x3c, 0x6c, 0x6e, 0x59, 0x3f,
0xe0, 0x4a, 0x9d, 0x98, 0x53, 0xf4, 0x04, 0xa0, 0xca, 0x25, 0x8e, 0x74, 0xcd, 0xbc, 0x63, 0x5f,
0x84, 0x8d, 0x1d, 0xf4, 0x0a, 0x20, 0x21, 0x79, 0x4e, 0x0a, 0x11, 0x2d, 0x01, 0x2e, 0x6f, 0x06,
0x0e, 0x97, 0x7a, 0xa2, 0x98, 0xa6, 0x11, 0x8d, 0x59, 0x9c, 0x73, 0x67, 0x54, 0x07, 0x85, 0x8d,
0x0b, 0x42, 0x97, 0x87, 0xb3, 0x13, 0xe8, 0xfa, 0x08, 0x57, 0xea, 0xc4, 0x9c, 0xb6, 0x78, 0x6b,
0xff, 0xcb, 0x7b, 0x0a, 0x86, 0x8f, 0xcb, 0xdb, 0x2c, 0x4e, 0x96, 0x47, 0xa5, 0xfd, 0x5d, 0xd6,
0xf9, 0xdf, 0x79, 0x4f, 0x5f, 0x8d, 0x29, 0x18, 0x1e, 0xce, 0x8e, 0xaf, 0xea, 0x83, 0xac, 0xb2,
0x52, 0xd5, 0x81, 0xb5, 0xf8, 0x04, 0xa6, 0x8f, 0x4b, 0x9f, 0x91, 0x15, 0x9d, 0xe0, 0x7c, 0xb6,
0xf9, 0x19, 0x3b, 0xdc, 0x5b, 0x1c, 0xb5, 0xbf, 0x38, 0x22, 0x1d, 0xee, 0x2f, 0x44, 0x8a, 0x5a,
0xc1, 0x66, 0x69, 0xfd, 0xd4, 0x60, 0xd8, 0x03, 0x70, 0xb0, 0x88, 0x56, 0x65, 0xcf, 0xda, 0x95,
0x15, 0x22, 0x3d, 0x9c, 0x75, 0x8b, 0x6c, 0x48, 0xd0, 0x76, 0x24, 0xec, 0x51, 0xa2, 0x19, 0x0c,
0x7b, 0xf2, 0x1f, 0xac, 0xf1, 0xe6, 0xd7, 0x5d, 0xa8, 0x8c, 0x0f, 0x25, 0xa0, 0xab, 0x5c, 0x07,
0x59, 0x4e, 0xe5, 0x94, 0x1d, 0x7e, 0x67, 0x3c, 0xeb, 0x8d, 0xe1, 0x54, 0x80, 0xa8, 0x2c, 0xa0,
0x06, 0xe9, 0x30, 0x9f, 0x1a, 0xa4, 0xd3, 0x47, 0x3e, 0xc3, 0x23, 0xc5, 0xc0, 0xa2, 0xe1, 0x96,
0xa4, 0x62, 0xa4, 0x0c, 0xab, 0x2f, 0xa4, 0x42, 0x50, 0x0c, 0x4f, 0x8d, 0xa0, 0x1e, 0x5a, 0xc3,
0xea, 0x0b, 0xe1, 0x14, 0x31, 0x18, 0x74, 0xf6, 0x37, 0x7a, 0xbe, 0xa5, 0xd9, 0xd9, 0x81, 0x86,
0xbd, 0x5f, 0x60, 0x85, 0xd9, 0xd9, 0x6f, 0x35, 0x66, 0x5f, 0xd7, 0xd7, 0x98, 0xbd, 0xed, 0x7b,
0xfb, 0xf4, 0xfd, 0x40, 0x3c, 0xb8, 0x51, 0x30, 0x69, 0xbc, 0xb4, 0xf2, 0xf2, 0x4b, 0xf9, 0x9d,
0x9d, 0xcb, 0xad, 0x17, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0xcd, 0x0e, 0x4c, 0xb2, 0x07,
0x00, 0x00,
}

View File

@ -1,85 +0,0 @@
syntax = "proto3";
import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto";
option go_package = "Open_IM/pkg/proto/cache;cache";
package cache;
message GetFriendIDListFromCacheReq {
string userID = 1;
string operationID = 2;
}
message GetFriendIDListFromCacheResp {
repeated string userIDList = 1;
server_api_params.CommonResp commonResp = 2;
}
message DelFriendIDListFromCacheReq {
string userID = 1;
string operationID = 2;
}
message DelFriendIDListFromCacheResp {
server_api_params.CommonResp commonResp = 1;
}
message GetBlackIDListFromCacheReq {
string userID = 1;
string operationID = 2;
}
message GetBlackIDListFromCacheResp {
repeated string userIDList = 1;
server_api_params.CommonResp commonResp = 2;
}
message DelBlackIDListFromCacheReq {
string userID = 1;
string operationID = 2;
}
message DelBlackIDListFromCacheResp {
server_api_params.CommonResp commonResp = 1;
}
message GetGroupMemberIDListFromCacheReq {
string operationID = 1;
string groupID = 2;
}
message GetGroupMemberIDListFromCacheResp {
server_api_params.CommonResp commonResp = 1;
repeated string userIDList = 2;
}
message DelGroupMemberIDListFromCacheReq {
string groupID = 1;
string operationID = 2;
}
message DelGroupMemberIDListFromCacheResp {
server_api_params.CommonResp commonResp = 1;
}
service cache{
// friendInfo
rpc GetFriendIDListFromCache(GetFriendIDListFromCacheReq) returns(GetFriendIDListFromCacheResp);
// for dtm
rpc DelFriendIDListFromCache(DelFriendIDListFromCacheReq) returns(DelFriendIDListFromCacheResp);
// blackList
rpc GetBlackIDListFromCache(GetBlackIDListFromCacheReq) returns(GetBlackIDListFromCacheResp);
// for dtm
rpc DelBlackIDListFromCache(DelBlackIDListFromCacheReq) returns (DelBlackIDListFromCacheResp);
// group
rpc GetGroupMemberIDListFromCache(GetGroupMemberIDListFromCacheReq) returns(GetGroupMemberIDListFromCacheResp);
// for dtm
rpc DelGroupMemberIDListFromCache(DelGroupMemberIDListFromCacheReq) returns(DelGroupMemberIDListFromCacheResp);
}