Connect to dispatcher only when the call is made

This commit is contained in:
TeoV
2020-05-28 13:12:14 +03:00
committed by Dan Christian Bogos
parent 530dd6fa59
commit 72d1e7fd2f
2 changed files with 7 additions and 21 deletions

View File

@@ -24,7 +24,6 @@ import (
"net"
"net/rpc"
"strings"
"syscall"
)
var (
@@ -244,11 +243,10 @@ func IsNetworkError(err error) bool {
if err == nil {
return false
}
if operr, ok := err.(*net.OpError); ok &&
(strings.HasSuffix(operr.Err.Error(),
syscall.ECONNRESET.Error()) ||
(strings.HasSuffix(operr.Err.Error(),
syscall.ECONNREFUSED.Error()))) { // connection reset
if _, isNetError := err.(*net.OpError); isNetError { // connection reset
return true
}
if _, isDNSError := err.(*net.DNSError); isDNSError {
return true
}
return err.Error() == rpc.ErrShutdown.Error() ||
@@ -256,8 +254,7 @@ func IsNetworkError(err error) bool {
err.Error() == ErrDisconnected.Error() ||
err.Error() == ErrReplyTimeout.Error() ||
err.Error() == ErrSessionNotFound.Error() ||
strings.HasPrefix(err.Error(), "rpc: can't find service") ||
strings.HasSuffix(err.Error(), "no such host")
strings.HasPrefix(err.Error(), "rpc: can't find service")
}
func ErrPathNotReachable(path string) error {