-
Notifications
You must be signed in to change notification settings - Fork 0
/
executor.go
43 lines (30 loc) · 1.09 KB
/
executor.go
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
package task
import (
"time"
)
type Executor interface {
Before(param *ExecutorParam) (err error) // 每次执行之前调用
Execute(param *ExecutorParam) (err error) // 执行
After(param *ExecutorParam) (err error) // 每次执行之后调用
}
type ExecutorParam struct {
Index int `json:"index"` // 索引号 从 0 开始
WorkerIndex int `json:"workerIndex"` // 执行线程编号
Extend interface{} `json:"extend"` // 扩展 业务自己数据可以放在此处
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
BeforeStartTime time.Time `json:"beforeStartTime"`
BeforeEndTime time.Time `json:"beforeEndTime"`
ExecuteStartTime time.Time `json:"executeStartTime"`
ExecuteEndTime time.Time `json:"executeEndTime"`
AfterStartTime time.Time `json:"afterStartTime"`
AfterEndTime time.Time `json:"afterEndTime"`
Error error `json:"error"`
isStop bool // isStop 是否需要停止
}
func (this_ *ExecutorParam) Stop() {
this_.isStop = true
}
func (this_ *ExecutorParam) IsStopped() bool {
return this_.isStop
}