Documentation ¶
Index ¶
- Variables
- func PollImmediateUntil(ctx context.Context, interval time.Duration, f ConditionFunc) error
- func PollWithBackoff(ctx context.Context, cfg PollConfig, f PollWithBackoffFunc) error
- type AttemptResult
- type BackoffManager
- type BackoffManagerFactory
- type ConditionFunc
- type PollConfig
- type PollConfigFactory
- type PollWithBackoffFunc
Constants ¶
This section is empty.
Variables ¶
var (
ErrWaitTimeout = wait.ErrWaitTimeout
)
Functions ¶
func PollImmediateUntil ¶
PollImmediateUntil is a wrapper to make the function more convenient to use. - ctx is used instead of a channel. - ctx is the first argument to follow the convention. - condition is the last argument because code is more readable this way when used with inline functions.
func PollWithBackoff ¶
func PollWithBackoff(ctx context.Context, cfg PollConfig, f PollWithBackoffFunc) error
PollWithBackoff runs f every duration given by BackoffManager.
If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f. It returns when: - context signals done. ErrWaitTimeout is returned in this case. - f returns Done
Types ¶
type AttemptResult ¶
type AttemptResult int
const ( // Continue means there was no error and polling can continue normally. Continue AttemptResult = iota // ContinueImmediately means there was no error and polling can continue normally. ContinueImmediately // Backoff means there was a retriable error, so the caller should try later. Backoff // Done means the polling should stop. There may or may not have been an error. Done )
type BackoffManager ¶
type BackoffManager = wait.BackoffManager
type BackoffManagerFactory ¶
type BackoffManagerFactory func() BackoffManager
func NewExponentialBackoffFactory ¶
func NewExponentialBackoffFactory(initBackoff, maxBackoff, resetDuration time.Duration, backoffFactor, jitter float64) BackoffManagerFactory
type ConditionFunc ¶
type ConditionFunc = wait.ConditionFunc
type PollConfig ¶ added in v14.2.0
type PollConfig struct { Backoff BackoffManager Interval time.Duration Sliding bool }
type PollConfigFactory ¶ added in v14.2.0
type PollConfigFactory func() PollConfig
func NewPollConfigFactory ¶ added in v14.2.0
func NewPollConfigFactory(interval time.Duration, backoff BackoffManagerFactory) PollConfigFactory
type PollWithBackoffFunc ¶
type PollWithBackoffFunc func() (error, AttemptResult)
PollWithBackoffFunc is a function that is called to perform polling. Signature is unusual because AttemptResult must be checked, not the error.