Documentation ¶
Index ¶
- Variables
- type TaskEvent
- type TaskFunc
- type TaskItem
- type TaskManager
- func (tm *TaskManager) AddTask(task *TaskItem)
- func (tm *TaskManager) Cancel(name string) error
- func (tm *TaskManager) CancelAll()
- func (tm *TaskManager) Get(name string) *TaskItem
- func (tm *TaskManager) Has(name string) bool
- func (tm *TaskManager) Names() []string
- func (tm *TaskManager) Register(name string, meta map[string]interface{}, tf TaskFunc) *TaskItem
- func (tm *TaskManager) RmTask(name string) error
- func (tm *TaskManager) Run(ctx context.Context, name string) error
- func (tm *TaskManager) Watch(ctx context.Context, name string, dependencies ...string) error
- type TaskState
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTaskNotFound = errors.New("task not found")
ErrTaskNotFound is returned when a task is not found
Functions ¶
This section is empty.
Types ¶
type TaskEvent ¶ added in v0.24.2
type TaskEvent struct { Name string `json:"name"` State TaskState `json:"state"` Meta map[string]interface{} `json:"meta"` }
func NewTaskEvent ¶ added in v0.24.2
type TaskItem ¶
TaskItem is the task item stored in the TaskManager
func NewTaskItem ¶
NewTaskItem creates a new task item
func (*TaskItem) UpdateMeta ¶ added in v0.24.2
UpdateMeta updates the meta data of the task
type TaskManager ¶
type TaskManager struct { sync.RWMutex *helper.EventEmitter[*TaskEvent] // contains filtered or unexported fields }
TaskManager allows you to create tasks and run them
func NewTaskManager ¶ added in v0.24.2
func NewTaskManager() *TaskManager
NewTaskManager creates a new task manager
func (*TaskManager) AddTask ¶
func (tm *TaskManager) AddTask(task *TaskItem)
AddTask adds a task to the task manager
func (*TaskManager) Has ¶
func (tm *TaskManager) Has(name string) bool
Has returns true if the task exists
func (*TaskManager) Names ¶
func (tm *TaskManager) Names() []string
Names returns the names of all the tasks
func (*TaskManager) Register ¶
func (tm *TaskManager) Register(name string, meta map[string]interface{}, tf TaskFunc) *TaskItem
Register creates a new task
func (*TaskManager) RmTask ¶
func (tm *TaskManager) RmTask(name string) error
RmTask removes a task from the task manager
type TaskState ¶ added in v0.24.2
type TaskState int
const ( // TaskStateIdle is the state when a task is idle TaskStateIdle TaskState = iota // TaskStateAdded is the state when a task is added TaskStateAdded // TaskStateRemoved is the state when a task is removed TaskStateRemoved // TaskStateWatching is the state when a task is watching TaskStateWatching // TaskStateRunning is the state when a task is running TaskStateRunning // TaskStateFinished is the state when a task is finished TaskStateFinished // TaskStateStopped is the state when a task is stopped TaskStateStopped // TaskStateFailed is the state when a task is failed TaskStateFailed )
Click to show internal directories.
Click to hide internal directories.