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

Function ResolveTCPAddrTimeout

pkg/utils/resolver.go:42–55  ·  view source on GitHub ↗
(addr string, timeout time.Duration)

Source from the content-addressed store, hash-verified

40}
41
42func ResolveTCPAddrTimeout(addr string, timeout time.Duration) *net.TCPAddr {
43 cntx, cancel := context.WithTimeout(context.Background(), timeout)
44 defer cancel()
45 var ch = make(chan *net.TCPAddr, 1)
46 go func() {
47 ch <- ResolveTCPAddr(addr)
48 }()
49 select {
50 case tcpAddr := <-ch:
51 return tcpAddr
52 case <-cntx.Done():
53 return nil
54 }
55}
56
57var (
58 Hostname, _ = os.Hostname()

Callers 1

Calls 2

ResolveTCPAddrFunction · 0.85
DoneMethod · 0.80

Tested by 1