mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
replace mongo driver
This commit is contained in:
parent
9a35af9fb2
commit
7cf712daff
@ -37,21 +37,21 @@ func init() {
|
||||
// mongo init
|
||||
// "mongodb://sysop:moon@localhost/records"
|
||||
// uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
uri := fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d",
|
||||
config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword,
|
||||
config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
|
||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil{
|
||||
log.NewError(" mongo.Connect failed, try ", err.Error(), uri)
|
||||
time.Sleep(time.Duration(30) * time.Second)
|
||||
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err1 != nil {
|
||||
log.NewError(" mongo.Connect failed, panic", err.Error(), uri)
|
||||
panic(err1.Error())
|
||||
}
|
||||
}
|
||||
//uri := fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d",
|
||||
// config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword,
|
||||
// config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase,
|
||||
// config.Config.Mongo.DBMaxPoolSize)
|
||||
//
|
||||
//mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
//if err != nil{
|
||||
// log.NewError(" mongo.Connect failed, try ", err.Error(), uri)
|
||||
// time.Sleep(time.Duration(30) * time.Second)
|
||||
// mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
// if err1 != nil {
|
||||
// log.NewError(" mongo.Connect failed, panic", err.Error(), uri)
|
||||
// panic(err1.Error())
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user