wait

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextOrGroupOrInterrupt

func ContextOrGroupOrInterrupt(ctx context.Context, wg *sync.WaitGroup)

ContextOrGroupOrInterrupt blocks until one of 3 things happens: the context deadline is met (if one exists), the wait group's Wait() function naturally unblocks, or we receive a SIGINT/SIGTERM signal.

func InterruptSignal

func InterruptSignal() chan os.Signal

InterruptSignal creates a channel that will accept the next SIGTERM or SIGINT signal the OS sends to this process. This call does NOT block - it is up to you to "<-" in or out of a 'select' to actually control program flow.

func WithTimeout

func WithTimeout(wg *sync.WaitGroup, timeout time.Duration) bool

WithTimeout waits for the given wait group to complete normally unless the given amount of time has passed. This handles the case where you expect your test to do N number of things, and you expect that they'll finish at least in a certain amount of time.

WARNING: If your wait group does not ever finish, this will leak a channel, so you should only use this in unit tests where you expect the lifespan of the process to be short!

Types

This section is empty.

Jump to

Keyboard shortcuts

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