github.com/docker/compose-on-kubernetes@v0.5.0/internal/e2e/wait/wait.go (about) 1 package wait 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 type condition func() (bool, error) 9 10 // For is a trivial polling loop. 11 func For(maxCount int, condition condition) error { 12 for i := 0; i < maxCount; i++ { 13 ok, err := condition() 14 if err != nil { 15 fmt.Println(err) 16 } else if ok { 17 return nil 18 } 19 20 time.Sleep(1 * time.Second) 21 } 22 23 return fmt.Errorf("condition not met after %d retries", maxCount) 24 }