You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/msg/server.go

77 lines
2.4 KiB

package msg
4 years ago
import (
2 years ago
"OpenIM/internal/common/check"
2 years ago
"OpenIM/pkg/common/db/cache"
2 years ago
"OpenIM/pkg/common/db/controller"
"OpenIM/pkg/common/db/localcache"
2 years ago
"OpenIM/pkg/common/db/unrelation"
2 years ago
"OpenIM/pkg/common/prome"
2 years ago
"OpenIM/pkg/discoveryregistry"
2 years ago
"OpenIM/pkg/proto/msg"
2 years ago
"google.golang.org/grpc"
)
type msgServer struct {
2 years ago
RegisterCenter discoveryregistry.SvcDiscoveryRegistry
MsgDatabase controller.MsgDatabase
ExtendMsgDatabase controller.ExtendMsgDatabase
Group *check.GroupChecker
User *check.UserCheck
Conversation *check.ConversationChecker
friend *check.FriendChecker
*localcache.GroupLocalCache
2 years ago
black *check.BlackChecker
MessageLocker MessageLocker
3 years ago
}
2 years ago
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
2 years ago
rdb, err := cache.NewRedis()
if err != nil {
return err
4 years ago
}
2 years ago
mongo, err := unrelation.NewMongo()
if err != nil {
return err
}
2 years ago
cacheModel := cache.NewCacheModel(rdb)
msgDocModel := unrelation.NewMsgMongoDriver(mongo.GetDatabase())
extendMsgModel := unrelation.NewExtendMsgSetMongoDriver(mongo.GetDatabase())
extendMsgDatabase := controller.NewExtendMsgDatabase(extendMsgModel)
msgDatabase := controller.NewMsgDatabase(msgDocModel, cacheModel)
s := &msgServer{
2 years ago
Conversation: check.NewConversationChecker(client),
User: check.NewUserCheck(client),
Group: check.NewGroupChecker(client),
MsgDatabase: msgDatabase,
ExtendMsgDatabase: extendMsgDatabase,
RegisterCenter: client,
GroupLocalCache: localcache.NewGroupLocalCache(client),
black: check.NewBlackChecker(client),
friend: check.NewFriendChecker(client),
2 years ago
MessageLocker: NewLockerMessage(cacheModel),
}
s.initPrometheus()
msg.RegisterMsgServer(server, s)
return nil
4 years ago
}
func (m *msgServer) initPrometheus() {
2 years ago
prome.NewMsgPullFromRedisSuccessCounter()
prome.NewMsgPullFromRedisFailedCounter()
prome.NewMsgPullFromMongoSuccessCounter()
prome.NewMsgPullFromMongoFailedCounter()
prome.NewSingleChatMsgRecvSuccessCounter()
prome.NewGroupChatMsgRecvSuccessCounter()
prome.NewWorkSuperGroupChatMsgRecvSuccessCounter()
prome.NewSingleChatMsgProcessSuccessCounter()
prome.NewSingleChatMsgProcessFailedCounter()
prome.NewGroupChatMsgProcessSuccessCounter()
prome.NewGroupChatMsgProcessFailedCounter()
prome.NewWorkSuperGroupChatMsgProcessSuccessCounter()
prome.NewWorkSuperGroupChatMsgProcessFailedCounter()
2 years ago
}