concurrency

package
v1.12.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrManagerAlreadyClosed = errors.New("runner manager already closed")
)
View Source
var ErrManagerAlreadyStarted = errors.New("runner manager already started")

Functions

This section is empty.

Types

type Runner added in v1.11.0

type Runner func(context.Context) error

Runner is a function that runs a task.

type RunnerCloserManager added in v1.12.0

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

RunnerCloserManager is a RunnerManager that also implements Closing of the added closers once the main runners are done.

func NewRunnerCloserManager added in v1.12.0

func NewRunnerCloserManager(gracePeriod *time.Duration, runners ...Runner) *RunnerCloserManager

NewRunnerCloserManager creates a new RunnerCloserManager with the given grace period and runners. If gracePeriod is nil, the grace period is infinite.

func (*RunnerCloserManager) Add added in v1.12.0

func (c *RunnerCloserManager) Add(runner ...Runner) error

Add implements RunnerManager.Add.

func (*RunnerCloserManager) AddCloser added in v1.12.0

func (c *RunnerCloserManager) AddCloser(closers ...any) error

AddCloser adds a closer to the list of closers to be closed once the main runners are done.

func (*RunnerCloserManager) Close added in v1.12.0

func (c *RunnerCloserManager) Close() error

Close will close the main runners and then the closers.

func (*RunnerCloserManager) Run added in v1.12.0

Add implements RunnerManager.Run.

func (*RunnerCloserManager) WaitUntilShutdown added in v1.12.0

func (c *RunnerCloserManager) WaitUntilShutdown()

WaitUntilShutdown will block until the main runners and closers are done.

type RunnerManager added in v1.11.0

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

RunnerManager is a manager for runners. It runs all runners in parallel and waits for all runners to finish. If any runner returns, the RunnerManager will stop all other runners and return any error.

func NewRunnerManager added in v1.11.0

func NewRunnerManager(runners ...Runner) *RunnerManager

NewRunnerManager creates a new RunnerManager.

func (*RunnerManager) Add added in v1.11.0

func (r *RunnerManager) Add(runner ...Runner) error

Add adds a new runner to the RunnerManager.

func (*RunnerManager) Run added in v1.11.0

func (r *RunnerManager) Run(ctx context.Context) error

Run runs all runners in parallel and waits for all runners to finish. If any runner returns, the RunnerManager will stop all other runners and return any error.

Jump to

Keyboard shortcuts

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