1 Star 0 Fork 0

h79/goutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
task.go 881 Bytes
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2023-04-12 14:20 . scheduler
package scheduler
type Task interface {
GetType() string
GetId() string
GetState() State
Execute() (interface{}, error)
Cancel()
Pause()
Start()
}
type State int
func (s State) Error() string {
return s.String()
}
func (s State) String() string {
switch s {
case InitState:
return "InitState"
case RunningState:
return "RunningState"
case PauseState:
return "PauseState"
case CancelState:
return "CancelState"
case CompletedState:
return "CompletedState"
case TimeoutState:
return "TimeoutState"
case ErrorState:
return "ErrorState"
}
return ""
}
func (s State) IsQuit() bool {
return s != RunningState && s != InitState && s != PauseState
}
const (
InitState = State(0)
RunningState = State(1)
PauseState = State(2)
CancelState = State(3)
CompletedState = State(4)
TimeoutState = State(5)
ErrorState = State(6)
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/h79/goutils.git
git@gitee.com:h79/goutils.git
h79
goutils
goutils
v1.8.79

搜索帮助

344bd9b3 5694891 D2dac590 5694891