From 8ecf67f60b7aa76d0a86d67d2bf6470d0d0fe0af Mon Sep 17 00:00:00 2001 From: yuyudeqiu <52580280+yuyudeqiu@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:29:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20bcs-common=20mongodb=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AEreplicaset=20(#3632)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bcs-common/pkg/odm/drivers/mongo/mongo.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bcs-common/pkg/odm/drivers/mongo/mongo.go b/bcs-common/pkg/odm/drivers/mongo/mongo.go index 85db5e5e0b..a84055c0a1 100644 --- a/bcs-common/pkg/odm/drivers/mongo/mongo.go +++ b/bcs-common/pkg/odm/drivers/mongo/mongo.go @@ -40,6 +40,7 @@ type Options struct { MaxPoolSize uint64 MinPoolSize uint64 Hosts []string + Replicaset string Monitor *event.CommandMonitor } @@ -67,6 +68,9 @@ func NewDB(opt *Options) (*DB, error) { Hosts: opt.Hosts, Monitor: opt.Monitor, } + if opt.Replicaset != "" { + mCliOpt.ReplicaSet = &opt.Replicaset + } if opt.MaxPoolSize != 0 { mCliOpt.MaxPoolSize = &opt.MaxPoolSize }