kubernetesk8s.io/kubernetes/pkg/util/wait Index | Files

package wait

import "k8s.io/kubernetes/pkg/util/wait"

Package wait provides tools for polling or listening for changes to a condition.

Index

Variables

var ErrWaitTimeout = errors.New("timed out waiting for the condition")

ErrWaitTimeout is returned when the condition exited without success

Functions

func Jitter

func Jitter(duration time.Duration, maxFactor float64) time.Duration

Jitter returns a time.Duration between duration and duration + maxFactor * duration, to allow clients to avoid converging on periodic behavior. If maxFactor is 0.0, a suggested default value will be chosen.

func Poll

func Poll(interval, timeout time.Duration, condition ConditionFunc) error

Poll tries a condition func until it returns true, an error, or the timeout is reached. condition will always be invoked at least once but some intervals may be missed if the condition takes too long or the time window is too short. If you pass maxTimes = 0, Poll will loop until condition returns true or an error.

func WaitFor

func WaitFor(wait WaitFunc, c ConditionFunc) error

WaitFor gets a channel from wait(), and then invokes c once for every value placed on the channel and once more when the channel is closed. If c returns an error the loop ends and that error is returned, and if c returns true the loop ends and nil is returned. ErrWaitTimeout will be returned if the channel is closed without c every returning true.

Types

type ConditionFunc

type ConditionFunc func() (done bool, err error)

ConditionFunc returns true if the condition is satisfied, or an error if the loop should be aborted.

type WaitFunc

type WaitFunc func() <-chan struct{}

WaitFunc creates a channel that receives an item every time a test should be executed and is closed when the last test should be invoked.

Source Files

doc.go wait.go

Version
v0.14.2
Published
Apr 8, 2015
Platform
js/wasm
Imports
3 packages
Last checked
21 seconds ago

Tools for package owners.