MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / WaitToConnect

Function WaitToConnect

utils/net.go:68–85  ·  view source on GitHub ↗

WaitToConnect returns only when port is ready to connect or canceled by context.

(ctx context.Context, bindAddr string, ports []int, interval time.Duration)

Source from the content-addressed store, hash-verified

66
67// WaitToConnect returns only when port is ready to connect or canceled by context.
68func WaitToConnect(ctx context.Context, bindAddr string, ports []int, interval time.Duration) (err error) {
69 for {
70 continueCheckC:
71 select {
72 case <-ctx.Done():
73 err = ctx.Err()
74 return
75 case <-time.After(interval):
76 for _, port := range ports {
77 addr := net.JoinHostPort(bindAddr, fmt.Sprint(port))
78 if !testPortConnectable(addr, 100*time.Millisecond) {
79 goto continueCheckC
80 }
81 }
82 return
83 }
84 }
85}
86
87// WaitForPorts returns only when port is ready to listen or canceled by context.
88func WaitForPorts(ctx context.Context, bindAddr string, ports []int, interval time.Duration) (err error) {

Callers 10

startNodesFunction · 0.92
TestFullProcessFunction · 0.92
startNodesFunction · 0.92
TestFullProcessFunction · 0.92
TestCQLDFunction · 0.92
TestStartBP_CallRPCFunction · 0.92
startNodesFunction · 0.92
startNodesFunction · 0.92
benchMinerFunction · 0.92
TestWaitForPortsFunction · 0.85

Calls 1

testPortConnectableFunction · 0.85

Tested by 10

startNodesFunction · 0.74
TestFullProcessFunction · 0.74
startNodesFunction · 0.74
TestFullProcessFunction · 0.74
TestCQLDFunction · 0.74
TestStartBP_CallRPCFunction · 0.74
startNodesFunction · 0.74
startNodesFunction · 0.74
benchMinerFunction · 0.74
TestWaitForPortsFunction · 0.68