Documentation ¶
Index ¶
- Variables
- type TaskExecutor
- func (te *TaskExecutor) Append(unit TaskUnit, maxRetry int) *TaskInfo
- func (te *TaskExecutor) AppendNoRetry(unit TaskUnit)
- func (te *TaskExecutor) Count() int
- func (te *TaskExecutor) Execute()
- func (te *TaskExecutor) FailedDeque() *lane.Deque
- func (te *TaskExecutor) Pause()
- func (te *TaskExecutor) Resume()
- func (te *TaskExecutor) SetParallel(parallel int)
- func (te *TaskExecutor) Stop()
- type TaskInfo
- type TaskInfoItem
- type TaskUnit
- type TaskUnitRunResult
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // TaskUnitRunResultSuccess 任务执行成功 TaskUnitRunResultSuccess = &TaskUnitRunResult{} )
Functions ¶
This section is empty.
Types ¶
type TaskExecutor ¶
type TaskExecutor struct { // 是否统计失败队列 IsFailedDeque bool // contains filtered or unexported fields }
func NewTaskExecutor ¶
func NewTaskExecutor() *TaskExecutor
func (*TaskExecutor) Append ¶
func (te *TaskExecutor) Append(unit TaskUnit, maxRetry int) *TaskInfo
Append 将任务加到任务队列末尾
func (*TaskExecutor) AppendNoRetry ¶
func (te *TaskExecutor) AppendNoRetry(unit TaskUnit)
AppendNoRetry 将任务加到任务队列末尾, 不重试
func (*TaskExecutor) FailedDeque ¶
func (te *TaskExecutor) FailedDeque() *lane.Deque
FailedDeque 获取失败队列
type TaskInfo ¶
type TaskInfo struct {
// contains filtered or unexported fields
}
func (*TaskInfo) SetMaxRetry ¶
type TaskInfoItem ¶
type TaskUnit ¶
type TaskUnit interface { SetTaskInfo(info *TaskInfo) // 执行任务 Run() (result *TaskUnitRunResult) // 重试任务执行的方法 // 当达到最大重试次数, 执行失败 OnRetry(lastRunResult *TaskUnitRunResult) // 每次执行成功执行的方法 OnSuccess(lastRunResult *TaskUnitRunResult) // 每次执行失败执行的方法 OnFailed(lastRunResult *TaskUnitRunResult) // 每次执行结束执行的方法, 不管成功失败 OnComplete(lastRunResult *TaskUnitRunResult) // 重试等待的时间 RetryWait() time.Duration }
Click to show internal directories.
Click to hide internal directories.