gpt4 book ai didi

mongodb - mongo-go-driver 的 clientOptions 默认值是多少?

转载 作者:数据小太阳 更新时间:2023-10-29 03:18:15 26 4
gpt4 key购买 nike

我试图为 mongo-go-driver 搜索 clientOptions 的默认值。

我正在尝试通过以下方式启动新客户:

        opts := options.ClientOptions{}
opts.ApplyURI(connectionURI)
sharedConnection, err = mongo.NewClient(&opts)

我想知道一些 clientOptions(例如 ConnectTimeout、MaxPoolSize、MaxConnIdleTime)的默认值是多少。

   type ClientOptions struct {
ConnectTimeout *time.Duration
Compressors []string
Dialer ContextDialer
HeartbeatInterval *time.Duration
LocalThreshold *time.Duration
MaxConnIdleTime *time.Duration
MaxPoolSize *uint16
Monitor *event.CommandMonitor
ReadConcern *readconcern.ReadConcern
ReadPreference *readpref.ReadPref
Registry *bsoncodec.Registry
RetryWrites *bool
ServerSelectionTimeout *time.Duration
Direct *bool
SocketTimeout *time.Duration
TLSConfig *tls.Config
WriteConcern *writeconcern.WriteConcern
ZlibLevel *int
}

最佳答案

以下默认是基于mongo-go-driver v1.1.x和MongoDB server v4.2。您还可以在 MongoDB driver specs 上找到更多信息/行为。 .

ConnectTimeout         30 * time.Second
Compressors nil (compression will not be used)
Dialer net.Dialer with a 300 second keepalive time
HeartbeatInterval 10 * time.Second
LocalThreshold 15 * time.Millisecond
MaxConnIdleTime nil (no limit)
MaxPoolSize 100
Monitor nil
ReadConcern nil (server default `local`)
ReadPreference readpref.Primary()
Registry bson.DefaultRegistry
RetryWrites true
ServerSelectionTimeout 30 * time.Second
Direct false
SocketTimeout nil (infinite)
TLSConfig nil
WriteConcern nil (server default `w:1`)
ZlibLevel 6 (if zlib compression enabled)

关于mongodb - mongo-go-driver 的 clientOptions 默认值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57828646/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com