test-errcode
wangchuxiao 2 years ago
parent 90e82ec2ef
commit 8c6c7ee21f

@ -68,11 +68,12 @@ func NewGroupServer(port int) *groupServer {
panic(err.Error()) panic(err.Error())
} }
registerIP, err := network.GetRpcIP(config.Config.RpcRegisterIP) registerIP, err := network.GetRpcIP(config.Config.RpcRegisterIP)
err = zkClient.Register(config.Config.RpcRegisterName.OpenImGroupName, registerIP, port) g.registerCenter = zkClient
err = g.registerCenter.Register(config.Config.RpcRegisterName.OpenImGroupName, registerIP, port)
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }
g.registerCenter = zkClient
//conns, err := g.registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName) //conns, err := g.registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName)
g.GroupInterface = controller.NewGroupInterface(controller.NewGroupDatabase(mysql.GormConn(), redis.GetClient(), mongo.GetClient())) g.GroupInterface = controller.NewGroupInterface(controller.NewGroupDatabase(mysql.GormConn(), redis.GetClient(), mongo.GetClient()))

@ -63,6 +63,9 @@ func (m *Mysql) InitConn() *Mysql {
sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.DBMaxLifeTime)) sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.DBMaxLifeTime))
sqlDB.SetMaxOpenConns(config.Config.Mysql.DBMaxOpenConns) sqlDB.SetMaxOpenConns(config.Config.Mysql.DBMaxOpenConns)
sqlDB.SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns) sqlDB.SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns)
if db == nil {
panic("db is nil")
}
m.SetGormConn(db) m.SetGormConn(db)
return m return m
} }
@ -89,8 +92,8 @@ func (w Writer) Printf(format string, args ...interface{}) {
func getDBConn(db *gorm.DB, tx []any) *gorm.DB { func getDBConn(db *gorm.DB, tx []any) *gorm.DB {
if len(tx) > 0 { if len(tx) > 0 {
if txDb, ok := tx[0].(*gorm.DB); ok { if txDB, ok := tx[0].(*gorm.DB); ok {
return txDb return txDB
} }
} }
return db return db

Loading…
Cancel
Save