|
@@ -98,8 +98,12 @@ func CreateDatabase(uri, dbName string, timeout ...time.Duration) (*mongo.Databa
|
|
|
// PreferServerCipherSuites: true,
|
|
|
//}
|
|
|
//o := options.Client().ApplyURI(uri).SetTLSConfig(tlsConfig)
|
|
|
-
|
|
|
- o := options.Client().ApplyURI(uri).SetMaxPoolSize(500)
|
|
|
+ o := options.Client().ApplyURI(uri).SetMaxPoolSize(500). //最大连接
|
|
|
+ SetMinPoolSize(20). //最小连接
|
|
|
+ SetMaxConnIdleTime(3 * time.Minute). //连接空闲时间
|
|
|
+ SetMaxConnIdleTime(5 * time.Minute). //连接生命周期
|
|
|
+ SetConnectTimeout(10 * time.Second). //连接超时时间
|
|
|
+ SetSocketTimeout(10 * time.Second) //套接字超时时间
|
|
|
if err := o.Validate(); err != nil {
|
|
|
return nil, err
|
|
|
}
|