var ForeverTestTimeout … var NeverStop … type Group … func (g *Group) Wait() { … } // StartWithChannel starts f in a new goroutine in the group. // stopCh is passed to f as an argument. f should stop when stopCh is available. func (g *Group) StartWithChannel(stopCh <-chan struct{ … } // StartWithContext starts f in a new goroutine in the group. // ctx is passed to f as an argument. f should stop when ctx.Done() is available. func (g *Group) StartWithContext(ctx context.Context, f func(context.Context)) { … } // Start starts f in a new goroutine in the group. func (g *Group) Start(f func()) { … } // Forever calls f every period for ever. // // Forever is syntactic sugar on top of Until. func Forever(f func(), period time.Duration) { … } // Jitter returns a time.Duration between duration and duration + maxFactor * // duration. // // This allows clients to avoid converging on periodic behavior. If maxFactor // is 0.0, a suggested default value will be chosen. func Jitter(duration time.Duration, maxFactor float64) time.Duration { … } type ConditionFunc … type ConditionWithContextFunc … // WithContext converts a ConditionFunc into a ConditionWithContextFunc func (cf ConditionFunc) WithContext() ConditionWithContextFunc { … } // ContextForChannel provides a context that will be treated as cancelled // when the provided parentCh is closed. The implementation returns // context.Canceled for Err() if and only if the parentCh is closed. func ContextForChannel(parentCh <-chan struct{ … } var _ … type channelContext … func (c channelContext) Done() <-chan struct{ … } func (c channelContext) Err() error { … } func (c channelContext) Deadline() (time.Time, bool) { … } func (c channelContext) Value(key any) any { … } // runConditionWithCrashProtection runs a ConditionFunc with crash protection. // // Deprecated: Will be removed when the legacy polling methods are removed. func runConditionWithCrashProtection(condition ConditionFunc) (bool, error) { … } // runConditionWithCrashProtectionWithContext runs a ConditionWithContextFunc // with crash protection. // // Deprecated: Will be removed when the legacy polling methods are removed. func runConditionWithCrashProtectionWithContext(ctx context.Context, condition ConditionWithContextFunc) (bool, error) { … } type waitFunc … // WithContext converts the WaitFunc to an equivalent WaitWithContextFunc func (w waitFunc) WithContext() waitWithContextFunc { … } type waitWithContextFunc … // waitForWithContext continually checks 'fn' as driven by 'wait'. // // waitForWithContext gets a channel from 'wait()”, and then invokes 'fn' // once for every value placed on the channel and once more when the // channel is closed. If the channel is closed and 'fn' // returns false without error, waitForWithContext returns ErrWaitTimeout. // // If 'fn' returns an error the loop ends and that error is returned. If // 'fn' returns true the loop ends and nil is returned. // // context.Canceled will be returned if the ctx.Done() channel is closed // without fn ever returning true. // // When the ctx.Done() channel is closed, because the golang `select` statement is // "uniform pseudo-random", the `fn` might still run one or multiple times, // though eventually `waitForWithContext` will return. // // Deprecated: Will be removed in a future release in favor of // loopConditionUntilContext. func waitForWithContext(ctx context.Context, wait waitWithContextFunc, fn ConditionWithContextFunc) error { … }