File size: 1,431 Bytes
7107f0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package tache

import "context"

// TaskBase is the base interface for all tasks
type TaskBase interface {
	// SetProgress sets the progress of the task
	SetProgress(progress float64)
	// GetProgress gets the progress of the task
	GetProgress() float64
	// SetState sets the state of the task
	SetState(state State)
	// GetState gets the state of the task
	GetState() State
	// GetID gets the ID of the task
	GetID() string
	// SetID sets the ID of the task
	SetID(id string)
	// SetErr sets the error of the task
	SetErr(err error)
	// GetErr gets the error of the task
	GetErr() error
	// SetCtx sets the context of the task
	SetCtx(ctx context.Context)
	// CtxDone gets the context done channel of the task
	CtxDone() <-chan struct{}
	// Cancel cancels the task
	Cancel()
	// Ctx gets the context of the task
	Ctx() context.Context
	// SetCancelFunc sets the cancel function of the task
	SetCancelFunc(cancelFunc context.CancelFunc)
	// GetRetry gets the retry of the task
	GetRetry() (int, int)
	// SetRetry sets the retry of the task
	SetRetry(retry int, maxRetry int)
	SetSize(size int64)
	GetSize() int64
	// Persist persists the task
	Persist()
	// SetPersist sets the persist function of the task
	SetPersist(persist func())
}

type Info interface {
	GetName() string
	GetStatus() string
}

// Task is the interface for all tasks
type Task interface {
	TaskBase
	Run() error
}

type TaskWithInfo interface {
	Task
	Info
}