util

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WaitTimedOut = xerrors.New("timeout waiting for condition")

Functions

func After added in v0.12.0

func After(clk quartz.Clock, d time.Duration) <-chan time.Time

After is a convenience function that returns a channel that will send the time after the given duration has elapsed using the provided clock. If clk is nil, a real clock will be used by default. Note that this function spawns a goroutine that will remain alive until the timer fires.

func GetUnexportedField added in v0.2.1

func GetUnexportedField[T any](obj *T, fieldName string) any

Based on https://stackoverflow.com/a/60598827

func WaitFor

func WaitFor(ctx context.Context, timeout WaitTimeout, condition func() (bool, error)) error

WaitFor waits for a condition to be true or the timeout to expire. It will wait for the condition to be true with exponential backoff. A single sleep timer is reused across iterations via Reset so that mock-clock tests always have a pending timer to advance.

Types

type WaitTimeout

type WaitTimeout struct {
	Timeout     time.Duration
	MinInterval time.Duration
	MaxInterval time.Duration
	InitialWait bool
	Clock       quartz.Clock
}

Jump to

Keyboard shortcuts

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