MCPcopy Index your code
hub / github.com/CodisLabs/codis / LookupIPTimeout

Function LookupIPTimeout

pkg/utils/resolver.go:22–35  ·  view source on GitHub ↗
(host string, timeout time.Duration)

Source from the content-addressed store, hash-verified

20}
21
22func LookupIPTimeout(host string, timeout time.Duration) []net.IP {
23 cntx, cancel := context.WithTimeout(context.Background(), timeout)
24 defer cancel()
25 var ch = make(chan []net.IP, 1)
26 go func() {
27 ch <- LookupIP(host)
28 }()
29 select {
30 case ipAddrs := <-ch:
31 return ipAddrs
32 case <-cntx.Done():
33 return nil
34 }
35}
36
37func ResolveTCPAddr(addr string) *net.TCPAddr {
38 tcpAddr, _ := net.ResolveTCPAddr("tcp", addr)

Callers 2

TestLookupIPTimeoutFunction · 0.85
initFunction · 0.85

Calls 2

LookupIPFunction · 0.85
DoneMethod · 0.80

Tested by 1

TestLookupIPTimeoutFunction · 0.68