fix: optimize isConnected to avoid url.String() conversions (#9202)

Stringifying in a loop can tax the system, avoid this
and convert the endpoints to strings early on and
remember them for the lifetime of the server.
This commit is contained in:
Harshavardhana
2020-03-24 18:53:24 -07:00
committed by GitHub
parent 38cf263409
commit 813e0fc1a8
3 changed files with 37 additions and 58 deletions

View File

@@ -171,7 +171,11 @@ func NewEndpoint(arg string) (ep Endpoint, e error) {
if isHostIP(arg) {
return ep, fmt.Errorf("invalid URL endpoint format: missing scheme http or https")
}
u = &url.URL{Path: path.Clean(arg)}
absArg, err := filepath.Abs(arg)
if err != nil {
return Endpoint{}, fmt.Errorf("absolute path failed %s", err)
}
u = &url.URL{Path: path.Clean(absArg)}
isLocal = true
}