@@ -76,6 +76,9 @@ type Config interface {
7676
7777 // UseDNSResolver is a flag about using dns-resolving or not
7878 UseDNSResolver () bool
79+
80+ // SharedPool is a flag about using shared connection pool or detached
81+ SharedPool () bool
7982}
8083
8184// Config contains driver configuration options.
@@ -88,6 +91,7 @@ type config struct {
8891 balancer balancer.Balancer
8992 secure bool
9093 dnsResolver bool
94+ sharedPool bool
9195 endpoint string
9296 database string
9397 requestsType string
@@ -98,6 +102,10 @@ type config struct {
98102 meta meta.Meta
99103}
100104
105+ func (c * config ) SharedPool () bool {
106+ return c .sharedPool
107+ }
108+
101109func (c * config ) UseDNSResolver () bool {
102110 return c .dnsResolver
103111}
@@ -211,9 +219,16 @@ func WithConnectionTTL(ttl time.Duration) Option {
211219 }
212220}
213221
222+ func WithSharedPool () Option {
223+ return func (c * config ) {
224+ c .sharedPool = true
225+ }
226+ }
227+
214228func WithCredentials (credentials credentials.Credentials ) Option {
215229 return func (c * config ) {
216230 c .credentials = credentials
231+ c .sharedPool = false // use separated pool for another credentials
217232 }
218233}
219234
@@ -231,6 +246,9 @@ func WithOperationCancelAfter(operationCancelAfter time.Duration) Option {
231246
232247func WithDialTimeout (timeout time.Duration ) Option {
233248 return func (c * config ) {
249+ if c .dialTimeout != timeout {
250+ c .sharedPool = false // use separated pool for another dial timeout
251+ }
234252 c .dialTimeout = timeout
235253 }
236254}
@@ -312,8 +330,9 @@ func certPool() (certPool *x509.CertPool) {
312330
313331func defaultConfig () (c * config ) {
314332 return & config {
315- balancer : balancers .Default (),
316- secure : true ,
333+ balancer : balancers .Default (),
334+ secure : true ,
335+ sharedPool : true ,
317336 tlsConfig : & tls.Config {
318337 MinVersion : tls .VersionTLS12 ,
319338 RootCAs : certPool (),
0 commit comments