Documentation ¶
Index ¶
- Constants
- type Config
- type Engine
- func (e *Engine[KEY]) AddFixedTasks(workerId int, generation int, tasks ...*Task[KEY]) error
- func (e *Engine[KEY]) AddNoPriorityTasks(tasks ...*Task[KEY])
- func (e *Engine[KEY]) AddTasks(generation int, tasks ...*Task[KEY])
- func (e *Engine[KEY]) AddWorker(num int)
- func (e *Engine[KEY]) AsyncAddTasks(generation int, tasks ...*Task[KEY])
- func (e *Engine[KEY]) Cancel()
- func (e *Engine[KEY]) CancelAfter(interval time.Duration) *Engine[KEY]
- func (e *Engine[KEY]) Context() context.Context
- func (e *Engine[KEY]) ErrHandler(errHandler func(task *Task[KEY])) *Engine[KEY]
- func (e *Engine[KEY]) ErrHandlerRetryTimes(times int) *Engine[KEY]
- func (e *Engine[KEY]) ErrHandlerUtilSuccess() *Engine[KEY]
- func (e *Engine[KEY]) ErrHandlerWriteToFile(path string) *Engine[KEY]
- func (e *Engine[KEY]) ExecTask(worker *Worker[KEY], task *Task[KEY])
- func (e *Engine[KEY]) KindGroupRandSpeedLimit(minInterval, maxInterval time.Duration, kinds ...Kind) *Engine[KEY]
- func (e *Engine[KEY]) KindGroupSpeedLimit(interval time.Duration, kinds ...Kind) *Engine[KEY]
- func (e *Engine[KEY]) KindLimiter(kind Kind, r rate.Limit, b int) *Engine[KEY]
- func (e *Engine[KEY]) KindRandSpeedLimit(kind Kind, minInterval, maxInterval time.Duration) *Engine[KEY]
- func (e *Engine[KEY]) KindSpeedLimit(kind Kind, interval time.Duration) *Engine[KEY]
- func (e *Engine[KEY]) Limiter(r rate.Limit, b int) *Engine[KEY]
- func (e *Engine[KEY]) MonitorInterval(interval time.Duration)
- func (e *Engine[KEY]) NewFixedWorker(interval time.Duration) int
- func (e *Engine[KEY]) RandSpeedLimited(minInterval, maxInterval time.Duration) *Engine[KEY]
- func (e *Engine[KEY]) Run(tasks ...*Task[KEY])
- func (e *Engine[KEY]) RunSingleWorker(tasks ...*Task[KEY])
- func (e *Engine[KEY]) SkipKind(kinds ...Kind) *Engine[KEY]
- func (e *Engine[KEY]) SpeedLimited(interval time.Duration) *Engine[KEY]
- func (e *Engine[KEY]) Stop()
- func (e *Engine[KEY]) StopAfter(interval time.Duration) *Engine[KEY]
- func (e *Engine[KEY]) StopCallBack(callBack func()) *Engine[KEY]
- func (e *Engine[KEY]) TaskSourceChannel(taskSourceChannel <-chan *Task[KEY])
- func (e *Engine[KEY]) TaskSourceFunc(taskSourceFunc func(*Engine[KEY]))
- type EngineStatistics
- type ErrHandle
- type Kind
- type KindHandler
- type Task
- type TaskFunc
- type TaskInterface
- type TaskMeta
- type TaskMetaNew
- type TaskStatistics
- type Tasks
- type Type
- type WorkStatistics
- type Worker
Constants ¶
View Source
const (
KindNormal = iota
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config[KEY comparable] struct { WorkerCount uint }
type Engine ¶
type Engine[KEY comparable] struct { EngineStatistics // contains filtered or unexported fields }
func NewEngine ¶
func NewEngine[KEY comparable](workerCount uint) *Engine[KEY]
func NewEngineWithContext ¶
func NewEngineWithContext[KEY comparable](workerCount uint, ctx context.Context) *Engine[KEY]
func (*Engine[KEY]) AddFixedTasks ¶
func (*Engine[KEY]) AddNoPriorityTasks ¶
func (*Engine[KEY]) AsyncAddTasks ¶
func (*Engine[KEY]) CancelAfter ¶
func (*Engine[KEY]) ErrHandler ¶
func (*Engine[KEY]) ErrHandlerRetryTimes ¶
func (*Engine[KEY]) ErrHandlerUtilSuccess ¶
func (*Engine[KEY]) ErrHandlerWriteToFile ¶
func (*Engine[KEY]) KindGroupRandSpeedLimit ¶
func (*Engine[KEY]) KindGroupSpeedLimit ¶
多个kind共用一个timer
func (*Engine[KEY]) KindLimiter ¶
func (*Engine[KEY]) KindRandSpeedLimit ¶
func (*Engine[KEY]) KindSpeedLimit ¶
func (*Engine[KEY]) MonitorInterval ¶
func (*Engine[KEY]) NewFixedWorker ¶
func (*Engine[KEY]) RandSpeedLimited ¶
func (*Engine[KEY]) RunSingleWorker ¶
func (*Engine[KEY]) SpeedLimited ¶
func (*Engine[KEY]) StopCallBack ¶
func (*Engine[KEY]) TaskSourceChannel ¶
TaskSourceChannel 任务源,参数是一个channel,channel关闭时,代表任务源停止发送任务
func (*Engine[KEY]) TaskSourceFunc ¶
TaskSourceFunc,参数为添加任务的函数,直到该函数运行结束,任务引擎才会检测任务是否结束
type EngineStatistics ¶
type EngineStatistics struct { WorkStatistics // contains filtered or unexported fields }
EngineStatistics 基本引擎统计数据
type KindHandler ¶
type KindHandler[KEY comparable] struct { Skip bool // TODO 指定Kind的Handler HandleFun TaskFunc[KEY] // contains filtered or unexported fields }
type Task ¶
type Task[KEY comparable] struct { TaskMeta[KEY] TaskFunc[KEY] // contains filtered or unexported fields }
type TaskInterface ¶ added in v1.5.0
type TaskInterface[KEY comparable] interface { Do(ctx context.Context) ([]*Task[KEY], error) }
type TaskMeta ¶
type TaskMeta[KEY comparable] struct { Kind Kind Key KEY Priority int Describe string TaskStatistics // contains filtered or unexported fields }
func (*TaskMeta[KEY]) SetPriority ¶
type TaskMetaNew ¶
type TaskMetaNew[T constraints.Key[KEY], KEY comparable] struct{}
type TaskStatistics ¶
type TaskStatistics struct {
// contains filtered or unexported fields
}
type Tasks ¶
type Tasks[KEY comparable] []*Task[KEY]
type WorkStatistics ¶
type WorkStatistics struct {
// contains filtered or unexported fields
}
WorkStatistics worker统计数据
Click to show internal directories.
Click to hide internal directories.