|
@@ -103,11 +103,24 @@ func CreateDatabase(uri, dbName string, tlsEnable int, maxClient uint64, timeout
|
|
MinVersion: tls.VersionTLS12,
|
|
MinVersion: tls.VersionTLS12,
|
|
PreferServerCipherSuites: true,
|
|
PreferServerCipherSuites: true,
|
|
}
|
|
}
|
|
- o = options.Client().ApplyURI(uri).SetTLSConfig(tlsConfig).SetMaxPoolSize(maxClient)
|
|
|
|
|
|
+
|
|
|
|
+ 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).SetTLSConfig(tlsConfig) //套接字超时时间
|
|
} else {
|
|
} else {
|
|
- o = options.Client().ApplyURI(uri).SetMaxPoolSize(maxClient)
|
|
|
|
|
|
+ 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 {
|
|
if err := o.Validate(); err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|