From 10f70e4896af4be8e915824ddc410d62b8e1755f Mon Sep 17 00:00:00 2001 From: carlchen Date: Wed, 11 Dec 2024 14:41:36 +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?= 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 }