I was trying to search for default values for clientOptions for mongo-go-driver.
I am trying to initiate new client in following way:
opts := options.ClientOptions{}
opts.ApplyURI(connectionURI)
sharedConnection, err = mongo.NewClient(&opts)
I was wondering what will be the default values for few of the clientOptions like 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
}
If there is not flow to set the default value then it will set to Zero Value. Zero Value is when a variable is declared, and not explicitly initialized, it will be allocated storage with a default value
another :
The following default is based on mongo-go-driver
v1.1.x and MongoDB server v4.2. You can also find out more information/behaviour on 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)