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
- func Await(pollInterval time.Duration, atMost time.Duration, until func() bool) error
- func AwaitBlocking(pollInterval time.Duration, atMost time.Duration, until func() bool) error
- func AwaitDefault(until func() bool) error
- func AwaitPanic(pollInterval time.Duration, atMost time.Duration, until func() bool)
- func AwaitPanicDefault(until func() bool)
- func IsAwaitTimeoutError(err error) bool
Constants ¶
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 ¶
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 ¶
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 ¶
AwaitDefault calls the "Await" function with a default pollInterval of 100 ms and a default atMost timeout of 10 seconds.
func AwaitPanic ¶
AwaitPanic calls Await but instead of returning an error it panics.
func AwaitPanicDefault ¶
func AwaitPanicDefault(until func() bool)
func IsAwaitTimeoutError ¶
IsAwaitTimeoutError checks if an error starts with the "TIMEOUT_ERROR" prefix.
Types ¶
This section is empty.