Documentation ¶
Overview ¶
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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 ¶
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 }