runner

package
v0.17.0 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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

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

func New

func New(name string, logger *zap.Logger) *Runner

func (*Runner) NumTasks

func (r *Runner) NumTasks() uint64

func (*Runner) Run

func (r *Runner) Run(f func(context.Context)) (context.CancelFunc, error)

Run executes f in a goroutine. It returns context.CancelFunc and error.

func (*Runner) RunC

func (r *Runner) RunC(ctx context.Context, f func(context.Context)) error

func (*Runner) State

func (r *Runner) State() State

func (*Runner) Stop

func (r *Runner) Stop()

Stop stops tasks in this runner.

func (*Runner) String

func (r *Runner) String() string

func (*Runner) WithManagedCancel

func (r *Runner) WithManagedCancel(parent context.Context) (context.Context, context.CancelFunc)

WithManagedCancel returns a copy of parent with a new Done channel. The returned context's Done channel is closed when the returned cancel function is called or when the parent context's Done channel is closed, whichever happens first. Moreover, the returned context is managed by runner, thus, if the runner is stopped, the context is also canceled.

Canceling this context releases resources associated with it, so code should call cancel as soon as the operations running in this Context complete.

type State

type State int
const (
	Invalid State = iota
	Running
	Stopping
	Stopped
)

func (State) String

func (i State) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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