| 265 | } |
| 266 | |
| 267 | func (s *Instance) waitUntilReady() error { |
| 268 | wg := &sync.WaitGroup{} |
| 269 | |
| 270 | onEndpointReady := func() { |
| 271 | wg.Done() |
| 272 | } |
| 273 | |
| 274 | // Start the servers, updating port numbers as necessary. |
| 275 | for _, ep := range s.endpoints { |
| 276 | wg.Add(1) |
| 277 | if err := ep.Start(onEndpointReady); err != nil { |
| 278 | return err |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | // Wait for all the servers to start. |
| 283 | wg.Wait() |
| 284 | |
| 285 | // Indicate that the server is now ready. |
| 286 | atomic.StoreUint32(&s.ready, 1) |
| 287 | |
| 288 | log.Info("Echo server is now ready") |
| 289 | return nil |
| 290 | } |
| 291 | |
| 292 | func (s *Instance) validate() error { |
| 293 | for _, port := range s.Ports { |