fix: changge the string ping format

This commit is contained in:
luhaoling 2024-03-04 11:10:10 +08:00
parent 261ea4706f
commit 39d5d3d89b

View File

@ -104,12 +104,11 @@ func buildMongoURI(config *config.GlobalConfig) string {
maxPoolSize = fmt.Sprint(config.Mongo.MaxPoolSize)
}
uriFormat := "mongodb://%s/%s?maxPoolSize=%s"
uriFormat := fmt.Sprintf("mongodb://%s/%s?maxPoolSize=%s", address, database, maxPoolSize)
if username != "" && password != "" {
uriFormat = "mongodb://%s:%s@%s/%s?maxPoolSize=%s"
return fmt.Sprintf(uriFormat, username, password, address, database, maxPoolSize)
return fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%s", username, password, address, database, maxPoolSize)
}
return fmt.Sprintf(uriFormat, address, database, maxPoolSize)
return uriFormat
}
func shouldRetry(err error) bool {