util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AwaitCondition

func AwaitCondition(cond func() bool, d time.Duration) bool

AwaitCondition waits until a given condition is satisfied or times out

func AwaitWaitGroup

func AwaitWaitGroup(wg *sync.WaitGroup, d time.Duration) bool

AwaitWaitGroup does a timed wait on the wait group

Types

type RunLifecycle

type RunLifecycle struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RunLifecycle manages the start/stop lifecycle for a runnable implementation

func NewRunLifecycle

func NewRunLifecycle(name string) *RunLifecycle

NewRunLifecycle returns a lifecycle object that can be used by a Runnable implementation to make sure the start/stop operations are idempotent

func (*RunLifecycle) Start

func (r *RunLifecycle) Start(action func() error) error

Start executes the given action if and on if lifecycle state is previously not started or stopped

func (*RunLifecycle) Status

func (r *RunLifecycle) Status() (bool, bool)

Status returns the status of this lifecycle as a pair of booleans (started, stopped).

func (*RunLifecycle) Stop

func (r *RunLifecycle) Stop(action func())

Stop stops the given action if and only if lifecycle state is previously started

Jump to

Keyboard shortcuts

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