1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package comm
- type TaskState int
- const (
- BT_STATE_QUITED_CACEL = -1 //loop取消退出
- BT_STATE_QUITED_EXCEPTION = -2 //loop异常退出
- BT_STATE_QUITED_NORMAL = -3 //loop退出
- BT_STATE_INIT = iota + 1 //初始化中
- BT_STATE_RUNING //正常运行中
- BT_STATE_EXCEPTION_RESTARTING //异常重启中
- BT_STATE_NORMAL_RESTARTING //主动重启中
- )
- type TaskRunCallback func(error)
- type Task interface {
- GetRuningState() TaskState
- CancelRuning()
- Restart()
- InitTask(interface{})
- Run(overCallback TaskRunCallback) error
- IsAsync() bool //是否异步任务 同步任务会等待执行完毕直接返回结果,异步任务,开启新线程后执行,不会等待结果
- GetNats() *NatsBus
- SetNats(*NatsBus)
- GetName() string
- SetName(string)
- GetID() string
- SetID(string)
- }
- type EventTask interface {
- Task
- RegistorEvent(events string, listen EventListener)
- //发送同步事件
- EmitEvent(name string, data interface{}) (interface{}, error)
- }
|