awaitility

package
v1.33.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package awaitility provides a simple mechanism to poll for conditions with a general timeout.

ported from: https://github.com/ecodia/golang-awaitility/blob/fb55e59708c71e8c4186a9310a2c233ca5474146/awaitility/awaitility.go, original license (MIT): https://github.com/ecodia/golang-awaitility/blob/fb55e59708c71e8c4186a9310a2c233ca5474146/LICENSE It is inspired by the great jvm lib "awaitility" (see https://github.com/awaitility/awaitility)

Index

Constants

View Source
const (
	// DefaultPollInterval The default poll interval (100 ms)
	DefaultPollInterval = 100 * time.Millisecond

	// DefaultAtMost The default maximum timeout (10 secs)
	DefaultAtMost = 10 * time.Second

	// TimeoutError The timeout error's prefix
	TimeoutError = "Await condition did not return true, limit reached"
)

Variables

This section is empty.

Functions

func Await

func Await(pollInterval time.Duration, atMost time.Duration, until func() bool) error

Await calls the "until" function initially and in the specified "pollInterval" until the total time spent exceeds the "atMost" limit. In this case an error is returned. There is no way of forcing a go routine to stop, so if the "until" function is long running it will continue to run in the background, even despite the Await function exiting after the atMost timeout.

func AwaitBlocking

func AwaitBlocking(pollInterval time.Duration, atMost time.Duration, until func() bool) error

AwaitBlocking It runs the "until" function inforeground so if the function runs longer than the atMost timeout, await does NOT abort. This is a tradeoff to have a determined state, the downside is that the function will not time out guranteed.

func AwaitDefault

func AwaitDefault(until func() bool) error

AwaitDefault calls the "Await" function with a default pollInterval of 100 ms and a default atMost timeout of 10 seconds.

func AwaitPanic

func AwaitPanic(pollInterval time.Duration, atMost time.Duration, until func() bool)

AwaitPanic calls Await but instead of returning an error it panics.

func AwaitPanicDefault

func AwaitPanicDefault(until func() bool)

func IsAwaitTimeoutError

func IsAwaitTimeoutError(err error) bool

IsAwaitTimeoutError checks if an error starts with the "TIMEOUT_ERROR" prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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