-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't call resolver if domain is already resolved #677
Don't call resolver if domain is already resolved #677
Conversation
Signed-off-by: Vladimir Popov <[email protected]>
|
||
u, err := url.Parse(fmt.Sprintf("tcp://%v:%v", ips[0].IP, records[0].Port)) | ||
var resolvedPattern = regexp.MustCompile("tcp://(?P<addr>[0-9.:]+):(?P<port>[0-9]+)?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just try to parse resolved domain
as a URL to check is it resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, any domain is most possible a valid URL. We need a domain in tcp://ip:port
format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets then check that part in URL after the scheme is a valid IP and PORT.
You could split Path into two strings entry to parse parts with default parsers for IP and int
serviceDomain := fmt.Sprintf("%v.%v", service, domain) | ||
_, records, err := r.LookupSRV(ctx, service, "tcp", serviceDomain) | ||
var resolved string | ||
if isResolved(domain) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this check to top-level before call resolve domain.
|
||
u, err := url.Parse(fmt.Sprintf("tcp://%v:%v", ips[0].IP, records[0].Port)) | ||
var resolvedPattern = regexp.MustCompile("tcp://(?P<addr>[0-9.:]+):(?P<port>[0-9]+)?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets then check that part in URL after the scheme is a valid IP and PORT.
You could split Path into two strings entry to parse parts with default parsers for IP and int
Signed-off-by: Vladimir Popov <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
…k@master networkservicemesh/sdk#677 networkservicemesh/sdk PR link: networkservicemesh/sdk#677 networkservicemesh/sdk commit message: commit cefb0ac33f42abd4b175cdc25184e1d78abe2d87 Author: Vladimir Popov <[email protected]> Date: Wed Jan 27 14:18:11 2021 +0700 Don't call resolver if domain is already resolved (#677) * Don't call resolver if domain is already resolved Signed-off-by: Vladimir Popov <[email protected]> * Rework isResolved() to parseIPPort() Signed-off-by: Vladimir Popov <[email protected]> Signed-off-by: NSMBot <[email protected]>
Motivation
There is no need to call resolver if domain is already in
tcp://${addr}:${port}
format.