MCPcopy Index your code
hub / github.com/perkeep/perkeep / AwaitReachable

Function AwaitReachable

internal/netutil/netutil.go:30–41  ·  view source on GitHub ↗

AwaitReachable tries to make a TCP connection to addr regularly. It returns an error if it's unable to make a connection before maxWait.

(addr string, maxWait time.Duration)

Source from the content-addressed store, hash-verified

28// AwaitReachable tries to make a TCP connection to addr regularly.
29// It returns an error if it's unable to make a connection before maxWait.
30func AwaitReachable(addr string, maxWait time.Duration) error {
31 done := time.Now().Add(maxWait)
32 for time.Now().Before(done) {
33 c, err := net.Dial("tcp", addr)
34 if err == nil {
35 c.Close()
36 return nil
37 }
38 time.Sleep(100 * time.Millisecond)
39 }
40 return fmt.Errorf("%v unreachable for %v", addr, maxWait)
41}
42
43// HostPort takes a urlStr string URL, and returns a host:port string suitable
44// to passing to net.Dial, with the port set as the scheme's default port if

Callers 3

lookupMethod · 0.92
makeThingsMethod · 0.92
mainFunction · 0.92

Calls 2

CloseMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected