MCPcopy Create free account
hub / github.com/cortexproject/cortex / getLocalHostPort

Function getLocalHostPort

integration/grpc_server_test.go:296–311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

294}
295
296func getLocalHostPort() (int, func() error, error) {
297 addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
298 if err != nil {
299 return 0, nil, err
300 }
301
302 l, err := net.ListenTCP("tcp", addr)
303 if err != nil {
304 return 0, nil, err
305 }
306
307 closePort := func() error {
308 return l.Close()
309 }
310 return l.Addr().(*net.TCPAddr).Port, closePort, nil
311}

Callers 1

runFunction · 0.70

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected