Until loops until stop channel is closed, running f every period

    1. func Until(f func(), period time.Duration, stopCh <-chan struct{}) {
    2. JitterUntil(f, period, 0.0, true, stopCh)
    3. }

    PollImmediateUntil tries a condition func until it returns true, an error or stopCh is closed

    1. func PollImmediateUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error {
    2. done, err := condition()
    3. if err != nil {
    4. return err
    5. }
    6. if done {
    7. return nil
    8. }
    9. select {
    10. case <-stopCh:
    11. return ErrWaitTimeout
    12. default:
    13. return PollUntil(interval, condition, stopCh)
    14. }
    15. }