Documentation
¶
Index ¶
Constants ¶
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 (*DXTask) IsActive ¶ added in v1.137.0
IsActive reports whether the task's goroutine is running.
func (*DXTask) StartShutdown ¶
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) 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.