-
Notifications
You must be signed in to change notification settings - Fork 89
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
Allow FQDN lookup functions to take context #199
Changes from 6 commits
fd1ad25
01b75c6
6eea02f
2b70234
b05739a
f64eb1b
8ef547d
ee500ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
Allow FQDN lookup functions to take a context. | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,10 @@ | |
|
||
package types | ||
|
||
import "time" | ||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
// Host is the interface that wraps methods for returning Host stats | ||
// It may return partial information if the provider | ||
|
@@ -28,7 +31,7 @@ type Host interface { | |
Memory() (*HostMemoryInfo, error) | ||
|
||
// FQDN returns the fully-qualified domain name of the host, lowercased. | ||
FQDN() (string, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change to the API. I suggest adding an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 8ef547d. |
||
FQDN(ctx context.Context) (string, error) | ||
} | ||
|
||
// NetworkCounters represents network stats from /proc/net | ||
|
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.
The type of
ips
here changed from[]net.IP
to[]net.IPAddr
which doesn't have the same implementation ofString()
, since net.IPAddr embedsIP
and extends it with a zone.If you want the exact same conversion as before you want to call
ip.IP.String()
I think.The original call to
net.LookupIP
stripped off the IPv6 zone: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/lookup.go;l=195There 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.
Are you sure? Before,
ips
was initialized as:Now, it's initialized as:
In both cases, the type of
ips
is the same:[]IP
.net.LookupIP
: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/lookup.go;l=193-205net.DefaultResolver.LookupIP
: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/net/lookup.go;l=213-234There 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.
Ah you are right for some reason I ended up focusing on LookupIPAddr as if it were called early, I think this was because
net.LookupIP
calls LookupIPAddr butfunc (r *Resolver) LookupIP
does something else.I don't have enough brainpower left for the day or network knowledge to know if that is significant, I was trying to quickly check if this worked the same as it did before.