wait

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithExponentialBackoff

func WithExponentialBackoff(opts Backoff, fn CondFunc) error

WithExponentialBackoff repeatedly invokes the function `fn` with exponentially growing/shrinking delay between the calls, until `fn` reports that it's done, or until it returns an error, or until a specified maximum number of retries. in the latter case a somewhat gRPC-specific Status with `DeadlineExceeded` error is returned.

see Backoff documentation of individual `opts` field definitions.

if opts.Delay is not positive - no delay will be introduced between fn() invocations. otherwise, the delay will be bounded by opts.DelayLimit, if the latter is specified.

if opts.Factor is not positive - the delay introduced will be constant, i.e. effective factor of 1.0. if 0 < opts.Factor < 1, the delay introduced will be shrinking, otherwise it'll be growing.

if opts.DelayLimit is not positive - the delay will be increased/decreased by the specified factor on every step. otherwise, the delay between steps will be modified by the specified factor up/down to the delay limit.

if opts.Retries is not positive - `fn` will not be invoked at all.

func WithRetries

func WithRetries(retries int, delay time.Duration, fn CondFunc) error

Types

type Backoff

type Backoff struct {
	Delay      time.Duration // initial delay between retries
	Factor     float64       // increase/decrease delay by this factor each step
	DelayLimit time.Duration // retry delay upper/lower bound
	Retries    int           // if unsuccessful - abort after this many retries
}

type CondFunc

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

Jump to

Keyboard shortcuts

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