MCPcopy
hub / github.com/labstack/echo / startOnRandomPort

Function startOnRandomPort

server_test.go:28–43  ·  view source on GitHub ↗
(ctx stdContext.Context, e *Echo)

Source from the content-addressed store, hash-verified

26)
27
28func startOnRandomPort(ctx stdContext.Context, e *Echo) (string, error) {
29 addrChan := make(chan string)
30 errCh := make(chan error)
31
32 go func() {
33 errCh <- (&StartConfig{
34 Address: ":0",
35 GracefulTimeout: 100 * time.Millisecond,
36 ListenerAddrFunc: func(addr net.Addr) {
37 addrChan <- addr.String()
38 },
39 }).Start(ctx, e)
40 }()
41
42 return waitForServerStart(addrChan, errCh)
43}
44
45func waitForServerStart(addrChan <-chan string, errCh <-chan error) (string, error) {
46 waitCtx, cancel := stdContext.WithTimeout(stdContext.Background(), 200*time.Millisecond)

Callers 1

Calls 3

waitForServerStartFunction · 0.85
StartMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…