wait

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package wait provides tools for polling or listening for changes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Jitter added in v0.3.0

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

Jitter returns a time.Duration between duration and duration + maxFactor * duration.

func Poll

func Poll(ctx context.Context, conditionFunc ConditionWithContextFunc, opts ...OptionFunc) error

Poll polls a condition until it returns true, an error, or the timeout is reached.

Types

type Backoff

type Backoff = wait.Backoff

Backoff is used to specify the backoff for the wait

type ConditionWithContextFunc

type ConditionWithContextFunc = wait.ConditionWithContextFunc

ConditionWithContextFunc is a function that can be used to poll a condition

type OptionFunc

type OptionFunc func(*Options)

OptionFunc is a function that can be used to configure the wait

func WithContinueOnError

func WithContinueOnError(continueOnError int) OptionFunc

WithContinueOnError configures the number of times the wait should continue on error

func WithExponentialBackoff

func WithExponentialBackoff(backoff *Backoff) OptionFunc

WithExponentialBackoff configures the wait to use exponential backoff

func WithImmediate

func WithImmediate() OptionFunc

WithImmediate configures the wait to be immediate

func WithInterval

func WithInterval(interval time.Duration) OptionFunc

WithInterval configures the interval for the wait

func WithTimeout

func WithTimeout(timeout time.Duration) OptionFunc

WithTimeout configures the timeout for the wait

type Options

type Options struct {
	// Interval is used to specify the interval for the wait
	Interval time.Duration
	// Timeout is used to specify the timeout for the wait
	Timeout time.Duration
	// Immediate is used to indicate if the wait should be immediate
	Immediate bool
	// ContinueOnError is used to specify the number of times the wait should continue on error
	ContinueOnError int
	// Backoff is used to specify the backoff for the wait
	Backoff *Backoff
}

Options is used to configure the wait

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL