Skip to content

Commit 861bb16

Browse files
authored
chore: simplify the code (#9)
1 parent 16ba7c2 commit 861bb16

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

multiple.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ func NewMultipleSqlConn(driverName string, conf DBConf, opts ...SqlOption) sqlx.
7171

7272
conn.p2cPicker.Store(newP2cPicker(followers, conn.accept))
7373

74-
ctx, cancelFunc := context.WithCancel(context.Background())
75-
proc.AddShutdownListener(func() {
76-
cancelFunc()
77-
})
78-
7974
if conn.enableFollower {
75+
ctx, cancelFunc := context.WithCancel(context.Background())
76+
proc.AddShutdownListener(func() {
77+
cancelFunc()
78+
})
8079
go conn.startFollowerHeartbeat(ctx)
8180
}
8281

0 commit comments

Comments
 (0)