@@ -87,20 +87,25 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
87
87
mc .parseTime = mc .cfg .ParseTime
88
88
89
89
// Connect to Server
90
- dialsLock .RLock ()
91
- dial , ok := dials [mc .cfg .Net ]
92
- dialsLock .RUnlock ()
93
- if ok {
94
- dctx := ctx
95
- if mc .cfg .Timeout > 0 {
96
- var cancel context.CancelFunc
97
- dctx , cancel = context .WithTimeout (ctx , c .cfg .Timeout )
98
- defer cancel ()
99
- }
100
- mc .netConn , err = dial (dctx , mc .cfg .Addr )
90
+ dctx := ctx
91
+ if mc .cfg .Timeout > 0 {
92
+ var cancel context.CancelFunc
93
+ dctx , cancel = context .WithTimeout (ctx , c .cfg .Timeout )
94
+ defer cancel ()
95
+ }
96
+
97
+ if c .cfg .DialFunc != nil {
98
+ mc .netConn , err = c .cfg .DialFunc (dctx , mc .cfg .Net , mc .cfg .Addr )
101
99
} else {
102
- nd := net.Dialer {Timeout : mc .cfg .Timeout }
103
- mc .netConn , err = nd .DialContext (ctx , mc .cfg .Net , mc .cfg .Addr )
100
+ dialsLock .RLock ()
101
+ dial , ok := dials [mc .cfg .Net ]
102
+ dialsLock .RUnlock ()
103
+ if ok {
104
+ mc .netConn , err = dial (dctx , mc .cfg .Addr )
105
+ } else {
106
+ nd := net.Dialer {}
107
+ mc .netConn , err = nd .DialContext (dctx , mc .cfg .Net , mc .cfg .Addr )
108
+ }
104
109
}
105
110
if err != nil {
106
111
return nil , err
0 commit comments