Documentation
¶
Overview ¶
Package netutil provides free port discovery, local IP, node info, and URL parsing.
Index ¶
- func FindFreePort(host string, maxAttempts int) (int, error)
- func GetLocalIP() (string, error)
- func IsAddrInUse(err error) bool
- func IsPrivateAddress(address string) (bool, error)deprecated
- func JoinURLs(list []*url.URL) string
- func ParseURLs(list []string) ([]*url.URL, error)
- func ParseURLsFromString(hosts string) ([]*url.URL, error)
- func WaitForNetwork(d time.Duration) (ipaddr string, err error)
- type GetNodeNameFn
- type NodeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindFreePort ¶
FindFreePort returns a free port found on a host
func GetLocalIP ¶
GetLocalIP returns the non loopback local IP of the host
func IsAddrInUse ¶
IsAddrInUse checks whether the given error indicates "address in use"
func IsPrivateAddress
deprecated
IsPrivateAddress reports whether address is loopback, link-local, or RFC1918/ULA.
Deprecated: use net.ParseIP(address) with net.IP.IsPrivate, IsLoopback, and IsLinkLocalUnicast. IsPrivate does not treat loopback or link-local as private; this helper does.
func ParseURLsFromString ¶
ParseURLsFromString creates a list of URLs from a coma-separated lists of hosts
Types ¶
type GetNodeNameFn ¶
GetNodeNameFn is an interface to return an application specific node name from the host name.
type NodeInfo ¶
NodeInfo is an interface to provide host and IP address for the node in the cluster.
func NewNodeInfo ¶
func NewNodeInfo(extractor GetNodeNameFn) (NodeInfo, error)
NewNodeInfo constructs node info using provided extractor function. If extractor is nil, then host name is used.