promise

package
v0.0.0-...-b044761 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(ff ...func()) (err error)

All a list of function to be executed

func Run

func Run(ff ...func() error) (err error)

Run check and run ff return error if one return error

Types

type Attempt

type Attempt struct {
	// contains filtered or unexported fields
}

Attempt defines a struct that contains attempt strategy

func (*Attempt) HasNext

func (a *Attempt) HasNext() bool

HasNext returns whether another attempt will be made if the current one fails. If it returns true, the following call to Next is guaranteed to return true.

func (*Attempt) Next

func (a *Attempt) Next() bool

Next waits until it is time to perform the next attempt or returns false if it is time to stop trying.

type AttemptStrategy

type AttemptStrategy struct {
	Total time.Duration // total duration of attempt.
	Delay time.Duration // interval between each try in the burst.
	Min   int           // minimum number of retries; overrides Total
}

AttemptStrategy represents a strategy for waiting for an action to complete successfully. This is an internal type used by the implementation of other packages.

func (AttemptStrategy) Start

func (s AttemptStrategy) Start() *Attempt

Start begins a new sequence of attempts for the given strategy.

type WaitGroup

type WaitGroup struct {
	// contains filtered or unexported fields
}

WaitGroup wrapper

func NewWaitGroup

func NewWaitGroup() *WaitGroup

NewWaitGroup creates a new WaitGroup of sync.WaitGroup

func (*WaitGroup) Add

func (wg *WaitGroup) Add(fs ...func())

Add given functions

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

Wait until group is done

func (*WaitGroup) WaitUntilTimeout

func (wg *WaitGroup) WaitUntilTimeout(timeout time.Duration) bool

WaitUntilTimeout waits for the waitgroup for the specified max timeout. Returns true if waiting timed out. Note that function added to waitgroup is still running without cancellation.

Jump to

Keyboard shortcuts

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