我正在尝试搜索mongo-go-driver的clientOptions的默认值。
我正在尝试通过以下方式启动新的客户端:
opts := options.ClientOptions{}
opts.ApplyURI(connectionURI)
sharedConnection, err = mongo.NewClient(&opts)我想知道像ConnectTimeout,MaxPoolSize,MaxConnIdleTime这样的clientOptions的默认值是多少。
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
}发布于 2019-09-11 14:05:30
以下默认值基于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)发布于 2019-09-07 06:42:39
如果没有流来设置默认值,那么它将设置为零值。零值是指声明变量且未显式初始化时,将使用默认值为其分配存储空间
另一个:
https://stackoverflow.com/questions/57828646
复制相似问题