Skip to content

Commit 55e2e30

Browse files
move to dial
1 parent 6f8ff77 commit 55e2e30

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

connection.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,6 @@ func Connect(addr string, opts Opts) (conn *Connection, err error) {
442442
}
443443
}
444444

445-
// Subscribe shutdown event to process graceful shutdown.
446-
if conn.isFeatureInSlice(WatchersFeature, conn.serverProtocolInfo.Features) {
447-
watcher, werr := conn.newWatcherImpl(shutdownEventKey, shutdownEventCallback)
448-
if werr != nil {
449-
conn.closeConnection(werr, true)
450-
return nil, werr
451-
}
452-
conn.shutdownWatcher = watcher
453-
}
454-
455445
return conn, err
456446
}
457447

@@ -625,6 +615,15 @@ func (conn *Connection) dial() (err error) {
625615
go conn.writer(w, connection)
626616
go conn.reader(r, connection)
627617

618+
// Subscribe shutdown event to process graceful shutdown.
619+
if conn.shutdownWatcher == nil && conn.isFeatureInSlice(WatchersFeature, conn.serverProtocolInfo.Features) {
620+
watcher, werr := conn.newWatcherImpl(shutdownEventKey, shutdownEventCallback)
621+
if werr != nil {
622+
return werr
623+
}
624+
conn.shutdownWatcher = watcher
625+
}
626+
628627
return
629628
}
630629

0 commit comments

Comments
 (0)