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