(conf *Config, timeout time.Duration, hks ...*HelloKite)
| 280 | } |
| 281 | |
| 282 | func WaitTillConnected(conf *Config, timeout time.Duration, hks ...*HelloKite) error { |
| 283 | k := kite.New("WaitTillConnected", "1.0.0") |
| 284 | k.Config = conf.Config.Copy() |
| 285 | |
| 286 | t := time.After(timeout) |
| 287 | |
| 288 | for { |
| 289 | select { |
| 290 | case <-t: |
| 291 | return fmt.Errorf("timed out waiting for %v after %s", hks, timeout) |
| 292 | default: |
| 293 | kites, err := k.GetKites(&protocol.KontrolQuery{ |
| 294 | Version: "1.0.0", |
| 295 | }) |
| 296 | if err != nil && err != kite.ErrNoKitesAvailable { |
| 297 | return err |
| 298 | } |
| 299 | |
| 300 | notReady := make(map[string]struct{}, len(hks)) |
| 301 | for _, hk := range hks { |
| 302 | notReady[hk.Kite.Kite().ID] = struct{}{} |
| 303 | } |
| 304 | |
| 305 | for _, kite := range kites { |
| 306 | delete(notReady, kite.Kite.ID) |
| 307 | } |
| 308 | |
| 309 | if len(notReady) == 0 { |
| 310 | return nil |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | func pause(args ...interface{}) { |
| 317 | if testing.Verbose() && interactive { |
no test coverage detected