Documentation ¶
Index ¶
- Constants
- Variables
- func GetUUID() string
- type AsyncTaskCallBack
- type AsyncTaskHandle
- type AsyncTaskInterface
- type AsyncTaskManagerInterface
- type DefaultAsyncTask
- func (t *DefaultAsyncTask) GetEndUnix() int64
- func (t *DefaultAsyncTask) GetError() error
- func (t *DefaultAsyncTask) GetStartUnix() int64
- func (t *DefaultAsyncTask) GetStatus() uint8
- func (t *DefaultAsyncTask) GetTag() *TaskTag
- func (t *DefaultAsyncTask) SetEndUnix(end int64)
- func (t *DefaultAsyncTask) SetError(e error)
- func (t *DefaultAsyncTask) SetStartUnix(start int64)
- func (t *DefaultAsyncTask) SetStatus(s uint8)
- type DefaultAsyncTaskManager
- func (m *DefaultAsyncTaskManager) AddAsyncTask(t AsyncTaskInterface, h AsyncTaskHandle, cbs ...AsyncTaskCallBack) error
- func (m *DefaultAsyncTaskManager) CheckTaskInWork(workTag string) (bool, error)
- func (m *DefaultAsyncTaskManager) GetManagerStatus() uint8
- func (m *DefaultAsyncTaskManager) GetWaitLength() int
- func (m *DefaultAsyncTaskManager) GetWorkerLength() int
- func (m *DefaultAsyncTaskManager) SetFinishCallBack(f func(*TaskManagerResult))
- func (m *DefaultAsyncTaskManager) SetProgressCallBack(p int, cb ProgressCallBack)
- func (m *DefaultAsyncTaskManager) SetTaskMaxLength(s int)
- func (m *DefaultAsyncTaskManager) SetWaitListMaxLength(l int)
- func (m *DefaultAsyncTaskManager) SetWorkPoolSize(s int)
- func (m *DefaultAsyncTaskManager) Start()
- func (m *DefaultAsyncTaskManager) Stop()
- func (m *DefaultAsyncTaskManager) TaskResultCallBack(res AsyncTaskInterface)
- type DefaultOneToManyTask
- func (t *DefaultOneToManyTask) Copy() OneToManyTaskInterface
- func (t *DefaultOneToManyTask) GetHandleResult() interface{}
- func (t *DefaultOneToManyTask) GetHandleTag() *TaskTag
- func (t *DefaultOneToManyTask) SetHandleResult(res interface{})
- func (t *DefaultOneToManyTask) SetHandleTag(tag *TaskTag)
- func (t *DefaultOneToManyTask) SetTaskTag(tag *TaskTag)
- type DefaultOneToManyTaskManager
- func (m *DefaultOneToManyTaskManager) AddAsyncTask(t OneToManyTaskInterface, cb func(res *OneToManyTaskResult), ...) error
- func (m *DefaultOneToManyTaskManager) CheckTaskInWork(workTag string) (bool, error)
- func (m *DefaultOneToManyTaskManager) FinishTouch()
- func (m *DefaultOneToManyTaskManager) GetManagerStatus() uint8
- func (m *DefaultOneToManyTaskManager) GetWaitLength() int
- func (m *DefaultOneToManyTaskManager) GetWorkerLength() int
- func (m *DefaultOneToManyTaskManager) SetWaitListMaxLength(l int)
- func (m *DefaultOneToManyTaskManager) SetWorkPoolSize(s int)
- func (m *DefaultOneToManyTaskManager) Start()
- func (m *DefaultOneToManyTaskManager) Stop()
- type OneToManyTaskHandleInterface
- type OneToManyTaskInterface
- type OneToManyTaskManagerInterface
- type OneToManyTaskResult
- type ProgressCallBack
- type TaskManagerResult
- type TaskProgress
- type TaskTag
Constants ¶
View Source
const ( ManagerInit uint8 = 0 ManagerStart uint8 = 1 ManagerStop uint8 = 2 ManagerFinish uint8 = 3 ManagerError uint8 = 4 )
View Source
const ( TaskONInit uint8 = 0 TaskONStart uint8 = 1 TaskONStop uint8 = 2 TaskONFinish uint8 = 3 TaskONError uint8 = 4 )
View Source
const ( DefaultWaitLength int = 1000 DefaultWorkLength int = 100 )
View Source
const TaskSep = "##ASYNCTASK%%"
Variables ¶
View Source
var UserStopError error
Functions ¶
Types ¶
type AsyncTaskHandle ¶
type AsyncTaskHandle interface { Start(AsyncTaskInterface) // 开始执行任务 Stop() // 结束任务,然后拉起回调,返回enmu.UserStopError SetHandleCallBack(f AsyncTaskCallBack) // 配置执行的回调 }
type AsyncTaskInterface ¶
type AsyncTaskManagerInterface ¶
type AsyncTaskManagerInterface interface { Start() // 开始 Stop() // 停止 SetWaitListMaxLength(l int) // 设置等待队列的最大长度,默认:1000 SetWorkPoolSize(s int) // 设置并行的数量,默认:100 AddAsyncTask(t AsyncTaskInterface, h AsyncTaskHandle, cb ...AsyncTaskCallBack) error // 增加一个异步任务 SetFinishCallBack(f func(*TaskManagerResult)) // 设置任务完成的回调,定长任务有效 CheckTaskInWork(tag string) (bool, error) // 查验任务是否在执行 GetWaitLength() int // 获取当前等待队列长度 GetWorkerLength() int // 获取当前工作队列长度 GetManagerStatus() uint8 // 获取管理器状态 SetTaskMaxLength(s int) // 设置最大任务数 SetProgressCallBack(p int, cb ProgressCallBack) // 设置进度回调,定长任务有效 }
AsyncTaskManagerInterface 异步任务管理器通用接口,几个Set方法尽量保证在Start()之前有效
type DefaultAsyncTask ¶
func (*DefaultAsyncTask) GetEndUnix ¶
func (t *DefaultAsyncTask) GetEndUnix() int64
func (*DefaultAsyncTask) GetError ¶
func (t *DefaultAsyncTask) GetError() error
func (*DefaultAsyncTask) GetStartUnix ¶
func (t *DefaultAsyncTask) GetStartUnix() int64
func (*DefaultAsyncTask) GetStatus ¶
func (t *DefaultAsyncTask) GetStatus() uint8
func (*DefaultAsyncTask) GetTag ¶
func (t *DefaultAsyncTask) GetTag() *TaskTag
func (*DefaultAsyncTask) SetEndUnix ¶
func (t *DefaultAsyncTask) SetEndUnix(end int64)
func (*DefaultAsyncTask) SetError ¶
func (t *DefaultAsyncTask) SetError(e error)
func (*DefaultAsyncTask) SetStartUnix ¶
func (t *DefaultAsyncTask) SetStartUnix(start int64)
func (*DefaultAsyncTask) SetStatus ¶
func (t *DefaultAsyncTask) SetStatus(s uint8)
type DefaultAsyncTaskManager ¶
type DefaultAsyncTaskManager struct {
// contains filtered or unexported fields
}
func NewDefaultAsyncTaskManager ¶
func NewDefaultAsyncTaskManager() *DefaultAsyncTaskManager
func (*DefaultAsyncTaskManager) AddAsyncTask ¶
func (m *DefaultAsyncTaskManager) AddAsyncTask(t AsyncTaskInterface, h AsyncTaskHandle, cbs ...AsyncTaskCallBack) error
func (*DefaultAsyncTaskManager) CheckTaskInWork ¶
func (m *DefaultAsyncTaskManager) CheckTaskInWork(workTag string) (bool, error)
func (*DefaultAsyncTaskManager) GetManagerStatus ¶
func (m *DefaultAsyncTaskManager) GetManagerStatus() uint8
func (*DefaultAsyncTaskManager) GetWaitLength ¶
func (m *DefaultAsyncTaskManager) GetWaitLength() int
func (*DefaultAsyncTaskManager) GetWorkerLength ¶
func (m *DefaultAsyncTaskManager) GetWorkerLength() int
func (*DefaultAsyncTaskManager) SetFinishCallBack ¶
func (m *DefaultAsyncTaskManager) SetFinishCallBack(f func(*TaskManagerResult))
func (*DefaultAsyncTaskManager) SetProgressCallBack ¶
func (m *DefaultAsyncTaskManager) SetProgressCallBack(p int, cb ProgressCallBack)
func (*DefaultAsyncTaskManager) SetTaskMaxLength ¶
func (m *DefaultAsyncTaskManager) SetTaskMaxLength(s int)
func (*DefaultAsyncTaskManager) SetWaitListMaxLength ¶
func (m *DefaultAsyncTaskManager) SetWaitListMaxLength(l int)
func (*DefaultAsyncTaskManager) SetWorkPoolSize ¶
func (m *DefaultAsyncTaskManager) SetWorkPoolSize(s int)
func (*DefaultAsyncTaskManager) Start ¶
func (m *DefaultAsyncTaskManager) Start()
func (*DefaultAsyncTaskManager) Stop ¶
func (m *DefaultAsyncTaskManager) Stop()
func (*DefaultAsyncTaskManager) TaskResultCallBack ¶
func (m *DefaultAsyncTaskManager) TaskResultCallBack(res AsyncTaskInterface)
type DefaultOneToManyTask ¶ added in v1.0.0
type DefaultOneToManyTask struct { *DefaultAsyncTask // contains filtered or unexported fields }
func NewDefaultOneToManyTask ¶ added in v1.0.0
func NewDefaultOneToManyTask(taskTarget string) *DefaultOneToManyTask
func (*DefaultOneToManyTask) Copy ¶ added in v1.0.0
func (t *DefaultOneToManyTask) Copy() OneToManyTaskInterface
func (*DefaultOneToManyTask) GetHandleResult ¶ added in v1.0.0
func (t *DefaultOneToManyTask) GetHandleResult() interface{}
func (*DefaultOneToManyTask) GetHandleTag ¶ added in v1.0.0
func (t *DefaultOneToManyTask) GetHandleTag() *TaskTag
func (*DefaultOneToManyTask) SetHandleResult ¶ added in v1.0.0
func (t *DefaultOneToManyTask) SetHandleResult(res interface{})
func (*DefaultOneToManyTask) SetHandleTag ¶ added in v1.0.0
func (t *DefaultOneToManyTask) SetHandleTag(tag *TaskTag)
func (*DefaultOneToManyTask) SetTaskTag ¶ added in v1.0.0
func (t *DefaultOneToManyTask) SetTaskTag(tag *TaskTag)
type DefaultOneToManyTaskManager ¶ added in v1.0.0
type DefaultOneToManyTaskManager struct {
// contains filtered or unexported fields
}
func (*DefaultOneToManyTaskManager) AddAsyncTask ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) AddAsyncTask(t OneToManyTaskInterface, cb func(res *OneToManyTaskResult), handles ...OneToManyTaskHandleInterface) error
func (*DefaultOneToManyTaskManager) CheckTaskInWork ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) CheckTaskInWork(workTag string) (bool, error)
func (*DefaultOneToManyTaskManager) FinishTouch ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) FinishTouch()
FinishTouch 任务完成后触发从等待队列加入到工作队列
func (*DefaultOneToManyTaskManager) GetManagerStatus ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) GetManagerStatus() uint8
func (*DefaultOneToManyTaskManager) GetWaitLength ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) GetWaitLength() int
func (*DefaultOneToManyTaskManager) GetWorkerLength ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) GetWorkerLength() int
func (*DefaultOneToManyTaskManager) SetWaitListMaxLength ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) SetWaitListMaxLength(l int)
func (*DefaultOneToManyTaskManager) SetWorkPoolSize ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) SetWorkPoolSize(s int)
func (*DefaultOneToManyTaskManager) Start ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) Start()
func (*DefaultOneToManyTaskManager) Stop ¶ added in v1.0.0
func (m *DefaultOneToManyTaskManager) Stop()
type OneToManyTaskHandleInterface ¶ added in v1.0.0
type OneToManyTaskHandleInterface interface { Start(AsyncTaskInterface) // 开始执行任务 Stop() // 结束任务,然后拉起回调,返回enmu.UserStopError SetHandleCallBack(f AsyncTaskCallBack) // 配置执行的回调 GetTarget() *TaskTag // 同一任务中唯一 }
OneToManyTaskHandleInterface 一对多异步任务Handle通用接口
type OneToManyTaskInterface ¶ added in v1.0.0
type OneToManyTaskInterface interface { AsyncTaskInterface SetTaskTag(tag *TaskTag) GetHandleTag() *TaskTag SetHandleTag(tag *TaskTag) GetHandleResult() interface{} SetHandleResult(res interface{}) Copy() OneToManyTaskInterface }
OneToManyTaskInterface 一对多异步任务通用接口
type OneToManyTaskManagerInterface ¶ added in v1.0.0
type OneToManyTaskManagerInterface interface { Start() // 开始 Stop() // 停止 SetWaitListMaxLength(l int) // 设置等待队列的最大长度,默认:1000 SetWorkPoolSize(s int) // 设置并行的数量,默认:100 AddAsyncTask(t OneToManyTaskInterface, cb func(res *OneToManyTaskResult), handles ...OneToManyTaskHandleInterface) error // 增加一个异步任务 CheckTaskInWork(tag string) (bool, error) // 查验任务是否在执行 GetWaitLength() int // 获取当前等待队列长度 GetWorkerLength() int // 获取当前工作队列长度 GetManagerStatus() uint8 // 获取管理器状态 }
OneToManyTaskManagerInterface 一对多异步任务管理通用接口
type OneToManyTaskResult ¶ added in v1.0.0
type OneToManyTaskResult struct { StartTime int64 EndTime int64 Status uint8 Task OneToManyTaskInterface ResultMap map[string]interface{} }
OneToManyTaskResult 一对多异步任务 执行结果
type TaskManagerResult ¶
type TaskManagerResult struct { StartTime int64 EndTime int64 Length uint64 TagsMap map[string]AsyncTaskInterface Status uint8 }
TaskManagerResult 任务管理器执行结果
Source Files ¶
Click to show internal directories.
Click to hide internal directories.