wait

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MPL-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wait polls until something the API reports is done, with a clock the caller passes in so tests never wait for real.

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timed out")

ErrTimeout is returned when the deadline passes before check reports done.

Functions

func Until

func Until(ctx context.Context, clock Clock, timeout time.Duration, interval time.Duration, check func(ctx context.Context) (bool, error)) error

Until calls check, then sleeps interval and calls it again, until check reports done, check fails, ctx is cancelled, or timeout has passed since the first call.

Types

type Clock

type Clock struct {
	Now   func() time.Time
	Sleep func(time.Duration)
}

Clock is the time source of a wait: the real one in main, a fake one in tests.

Jump to

Keyboard shortcuts

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