From 5b29273425ae997942b235b5aef7dcacc8f0354e Mon Sep 17 00:00:00 2001 From: dong Date: Mon, 16 Oct 2023 05:46:18 +0000 Subject: [PATCH] fix: mogodb url connent --- tools/component/component.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index dc89c7889..b2179ae67 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -158,6 +158,8 @@ func checkMysql() error { func checkMongo() error { var client *mongo.Client + uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority" + defer func() { if client != nil { client.Disconnect(context.TODO()) @@ -184,9 +186,7 @@ func checkMongo() error { config.Config.Mongo.MaxPoolSize) } } - client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( - fmt.Sprintf("mongodb://%v:%v@%v/?authSource=admin", - config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts))) + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri) if err != nil { return errs.Wrap(err) } else {