Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackoffWithContext ¶
func BackoffWithContext(ctx context.Context, backoff wait.Backoff, condition wait.ConditionFunc) error
BackoffWithContext repeats a condition check with exponential backoff, exiting early if the provided context is canceled.
It repeatedly checks the condition and then sleeps, using `backoff.Step()` to determine the length of the sleep and adjust Duration and Steps. Stops and returns as soon as: 1. the condition check returns true or an error, or 2. the context is canceled. In case (1) the returned error is what the condition function returned. In all other cases, ErrWaitTimeout is returned.
Adapted from wait.ExponentialBackoff in https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/wait/wait.go
Types ¶
type SingleRunner ¶
type SingleRunner struct {
// contains filtered or unexported fields
}
SingleRunner wraps an errgroup to run keyed goroutines as singletons. Keys are single-use and subsequent usage to schedule will be silently ignored. Goroutines can be individually canceled provided they respect the context passed to them.
func RunnerWithContext ¶
func RunnerWithContext(ctx context.Context) *SingleRunner
RunnerWithContext returns an initialized SingleRunner. The provided context is used as the parent of subsequently scheduled goroutines.
func (*SingleRunner) Cancel ¶
func (s *SingleRunner) Cancel(key string)
Cancel cancels a keyed goroutine if it exists.
func (*SingleRunner) Go ¶
Go schedules the provided function on a new goroutine if the provided key has not been used for scheduling before.
func (*SingleRunner) Wait ¶
func (s *SingleRunner) Wait() error
Wait waits for all goroutines managed by the SingleRunner to complete. Returns the first error returned from a managed goroutine, or nil.