Skip to content

Commit d2f8316

Browse files
committed
GODRIVER-2846 Update comments on ClientOptions.SetDialer(). (#1337)
1 parent 43ccd68 commit d2f8316

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

mongo/options/clientoptions.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -586,18 +586,17 @@ func (c *ClientOptions) SetCompressors(comps []string) *ClientOptions {
586586
return c
587587
}
588588

589-
// SetConnectTimeout specifies a timeout that is used for creating connections to the server. If a custom Dialer is
590-
// specified through SetDialer, this option must not be used. This can be set through ApplyURI with the
591-
// "connectTimeoutMS" (e.g "connectTimeoutMS=30") option. If set to 0, no timeout will be used. The default is 30
592-
// seconds.
589+
// SetConnectTimeout specifies a timeout that is used for creating connections to the server. This can be set through
590+
// ApplyURI with the "connectTimeoutMS" (e.g "connectTimeoutMS=30") option. If set to 0, no timeout will be used. The
591+
// default is 30 seconds.
593592
func (c *ClientOptions) SetConnectTimeout(d time.Duration) *ClientOptions {
594593
c.ConnectTimeout = &d
595594
return c
596595
}
597596

598-
// SetDialer specifies a custom ContextDialer to be used to create new connections to the server. The default is a
599-
// net.Dialer with the Timeout field set to ConnectTimeout. See https://golang.org/pkg/net/#Dialer for more information
600-
// about the net.Dialer type.
597+
// SetDialer specifies a custom ContextDialer to be used to create new connections to the server. This method overrides
598+
// the default net.Dialer, so dialer options such as Timeout, KeepAlive, Resolver, etc can be set.
599+
// See https://golang.org/pkg/net/#Dialer for more information about the net.Dialer type.
601600
func (c *ClientOptions) SetDialer(d ContextDialer) *ClientOptions {
602601
c.Dialer = d
603602
return c

x/mongo/driver/topology/connection_options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ func newConnectionConfig(opts ...ConnectionOption) *connectionConfig {
8383
}
8484

8585
if cfg.dialer == nil {
86+
// Use a zero value of net.Dialer when nothing is specified, so the Go driver applies default default behaviors
87+
// such as Timeout, KeepAlive, DNS resolving, etc. See https://golang.org/pkg/net/#Dialer for more information.
8688
cfg.dialer = &net.Dialer{}
8789
}
8890

0 commit comments

Comments
 (0)