rpc: Better connection handling (#10714)

This commit is contained in:
Preston Van Loon 2022-05-18 21:53:24 -05:00 committed by GitHub
parent 0d2696ed4e
commit ee6aa4d4ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,9 @@ func (s *Service) pollConnectionStatus(ctx context.Context) {
continue
}
// Close previous client, if connection was successful.
currClient.Close()
if currClient != nil {
currClient.Close()
}
log.Infof("Connected to new endpoint: %s", logs.MaskCredentialsLogging(s.cfg.currHttpEndpoint.Url))
return
case <-s.ctx.Done():
@ -92,7 +94,9 @@ func (s *Service) retryExecutionClientConnection(ctx context.Context, err error)
return
}
// Close previous client, if connection was successful.
currClient.Close()
if currClient != nil {
currClient.Close()
}
// Reset run error in the event of a successful connection.
s.runError = nil
}
@ -114,7 +118,9 @@ func (s *Service) checkDefaultEndpoint(ctx context.Context) {
return
}
// Close previous client, if connection was successful.
currClient.Close()
if currClient != nil {
currClient.Close()
}
s.updateCurrHttpEndpoint(primaryEndpoint)
}