Documentation ¶
Overview ¶
Package task manage task, such as file upload, file copy between storages, offline download, etc.
Index ¶
- Variables
- type Callback
- type Func
- type Manager
- func (tm *Manager[K]) Cancel(tid K) error
- func (tm *Manager[K]) ClearDone()
- func (tm *Manager[K]) ClearSucceeded()
- func (tm *Manager[K]) Get(tid K) (*Task[K], bool)
- func (tm *Manager[K]) GetAll() []*Task[K]
- func (tm *Manager[K]) GetByStates(states ...string) []*Task[K]
- func (tm *Manager[K]) ListDone() []*Task[K]
- func (tm *Manager[K]) ListUndone() []*Task[K]
- func (tm *Manager[K]) MustGet(tid K) *Task[K]
- func (tm *Manager[K]) RawTasks() *generic_sync.MapOf[K, *Task[K]]
- func (tm *Manager[K]) Remove(tid K) error
- func (tm *Manager[K]) RemoveAll()
- func (tm *Manager[K]) RemoveByStates(states ...string)
- func (tm *Manager[K]) Retry(tid K) error
- func (tm *Manager[K]) Submit(task *Task[K]) K
- type Task
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTaskNotFound = errors.New("task not found") ErrTaskRunning = errors.New("task is running") )
View Source
var ( PENDING = "pending" RUNNING = "running" SUCCEEDED = "succeeded" CANCELING = "canceling" CANCELED = "canceled" ERRORED = "errored" )
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback[K comparable] func(task *Task[K])
type Func ¶
type Func[K comparable] func(task *Task[K]) error
type Manager ¶
type Manager[K comparable] struct { // contains filtered or unexported fields }
func NewTaskManager ¶
func NewTaskManager[K comparable](maxWorker int, updateID ...func(*K)) *Manager[K]
func (*Manager[K]) ClearSucceeded ¶ added in v3.14.0
func (tm *Manager[K]) ClearSucceeded()
func (*Manager[K]) GetByStates ¶
func (*Manager[K]) ListUndone ¶
func (*Manager[K]) RemoveAll ¶
func (tm *Manager[K]) RemoveAll()
RemoveAll removes all tasks from the manager, this maybe shouldn't be used because the task maybe still running.
func (*Manager[K]) RemoveByStates ¶
type Task ¶
type Task[K comparable] struct { ID K Name string Error error Func Func[K] Ctx context.Context // contains filtered or unexported fields }
func WithCancelCtx ¶
func WithCancelCtx[K comparable](task *Task[K]) *Task[K]
func (Task[K]) GetProgress ¶
func (*Task[K]) SetProgress ¶
Click to show internal directories.
Click to hide internal directories.