瀏覽代碼

AuthSource

wcc 2 年之前
父節點
當前提交
ea016bbefb
共有 1 個文件被更改,包括 12 次插入10 次删除
  1. 12 10
      mongodb/mongodb.go

+ 12 - 10
mongodb/mongodb.go

@@ -306,14 +306,15 @@ type MongodbSim struct {
 	MongodbAddr string
 	Size        int
 	//	MinSize     int
-	DbName   string
-	C        *mongo.Client
-	Ctx      context.Context
-	ShortCtx context.Context
-	pool     chan bool
-	UserName string
-	Password string
-	ReplSet  string
+	DbName     string
+	C          *mongo.Client
+	Ctx        context.Context
+	ShortCtx   context.Context
+	pool       chan bool
+	UserName   string
+	Password   string
+	ReplSet    string
+	AuthSource string
 }
 
 func (m *MongodbSim) GetMgoConn() *MgoSess {
@@ -345,8 +346,9 @@ func (m *MongodbSim) InitPool() {
 	opts.SetMaxPoolSize(uint64(m.Size))
 	if m.UserName != "" && m.Password != "" {
 		cre := options.Credential{
-			Username: m.UserName,
-			Password: m.Password,
+			Username:   m.UserName,
+			Password:   m.Password,
+			AuthSource: m.AuthSource,
 		}
 		opts.SetAuth(cre)
 	}