Skip to content

Commit 7944564

Browse files
committed
Enable "SucceededEvent" and "FailedEvent" on nil conn.
1 parent 26368d8 commit 7944564

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

x/mongo/driver/topology/server.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -807,18 +807,18 @@ func (s *Server) check() (description.Server, error) {
807807
// Create a new connection and add it's handshake RTT as a sample.
808808
err = s.setupHeartbeatConnection()
809809
duration = time.Since(start)
810+
connID = "0"
811+
if s.conn != nil {
812+
connID = s.conn.ID()
813+
}
810814
if err == nil {
811815
// Use the description from the connection handshake as the value for this check.
812816
s.rttMonitor.addSample(s.conn.helloRTT)
813817
descPtr = &s.conn.desc
814-
if s.conn != nil {
815-
s.publishServerHeartbeatSucceededEvent(s.conn.ID(), duration, s.conn.desc, false)
816-
}
818+
s.publishServerHeartbeatSucceededEvent(connID, duration, s.conn.desc, false)
817819
} else {
818820
err = unwrapConnectionError(err)
819-
if s.conn != nil {
820-
s.publishServerHeartbeatFailedEvent(s.conn.ID(), duration, err, false)
821-
}
821+
s.publishServerHeartbeatFailedEvent(connID, duration, err, false)
822822
}
823823
} else {
824824
// An existing connection is being used. Use the server description properties to execute the right heartbeat.

0 commit comments

Comments
 (0)