task

package
v1.137.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DXTaskDefaultAfterDelaySec = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type DXTask

type DXTask struct {
	NameId        string
	StartAt       string
	AfterDelaySec int64
	OnExecute     DXTaskOnExecute
	Log           log.DXLog
	// RuntimeIsActive is true from StartAndWait until the task's goroutine has
	// ended. dxlib reads and writes it under runtimeMu; from elsewhere use
	// IsActive.
	RuntimeIsActive bool

	Context context.Context
	Cancel  context.CancelFunc
	// contains filtered or unexported fields
}

func (*DXTask) ApplyConfigurations

func (a *DXTask) ApplyConfigurations() (err error)

func (*DXTask) IsActive added in v1.137.0

func (a *DXTask) IsActive() bool

IsActive reports whether the task's goroutine is running.

func (*DXTask) StartAndWait

func (a *DXTask) StartAndWait(errorGroup *errgroup.Group) error

func (*DXTask) StartShutdown

func (a *DXTask) StartShutdown() (err error)

StartShutdown cancels the task's context. Cancelling is safe at any time, so it does not depend on whether the goroutine has started yet.

type DXTaskManager

type DXTaskManager struct {
	Context           context.Context
	Cancel            context.CancelFunc
	Tasks             map[string]*DXTask
	ErrorGroup        *errgroup.Group
	ErrorGroupContext context.Context
	// contains filtered or unexported fields
}
var Manager DXTaskManager

func (*DXTaskManager) NewTask

func (am *DXTaskManager) NewTask(nameId string, startAt string, afterDelaySec int64, onExecute DXTaskOnExecute) (*DXTask, error)

func (*DXTaskManager) StartAll

func (am *DXTaskManager) StartAll(errorGroup *errgroup.Group, errorGroupContext context.Context) error

func (*DXTaskManager) StopAll

func (am *DXTaskManager) StopAll() (err error)

StopAll cancels every task StartAll started, waits until each has ended and returns the first error a task ended with. It waits only for the goroutines StartAll added: the rest of the error group (an API server, say) is the business of whoever stops it.

type DXTaskOnExecute

type DXTaskOnExecute func(task *DXTask) error

Jump to

Keyboard shortcuts

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