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

67 lines
2.0 KiB

package msg
4 years ago
import (
2 years ago
"OpenIM/internal/common/check"
"OpenIM/pkg/common/db/controller"
"OpenIM/pkg/common/db/localcache"
"OpenIM/pkg/common/db/relation"
2 years ago
relationTb "OpenIM/pkg/common/db/table/relation"
2 years ago
discoveryRegistry "OpenIM/pkg/discoveryregistry"
"github.com/OpenIMSDK/openKeeper"
2 years ago
"OpenIM/pkg/common/prome"
2 years ago
"OpenIM/pkg/proto/msg"
2 years ago
"google.golang.org/grpc"
)
type msgServer struct {
RegisterCenter discoveryRegistry.SvcDiscoveryRegistry
2 years ago
MsgDatabase controller.MsgDatabase
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
}
func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
mysql, err := relation.NewGormDB()
if err != nil {
return err
4 years ago
}
2 years ago
if err := mysql.AutoMigrate(&relationTb.UserModel{}); err != nil {
return err
}
s := &msgServer{
Conversation: check.NewConversationChecker(client),
User: check.NewUserCheck(client),
Group: check.NewGroupChecker(client),
2 years ago
//MsgDatabase: controller.MsgDatabase(),
RegisterCenter: client,
GroupLocalCache: localcache.NewGroupMemberIDsLocalCache(client),
black: check.NewBlackChecker(client),
friend: check.NewFriendChecker(client),
}
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
}