Documentation ¶
Index ¶
- Constants
- type Config
- type Engine
- func (e *Engine[KEY, T, W]) AddFixedTasks(workerId int, generation int, tasks ...*Task[KEY, T]) error
- func (e *Engine[KEY, T, W]) AddNoPriorityTasks(tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddTasks(generation int, tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddWorker(num int)
- func (e *Engine[KEY, T, W]) AsyncAddTasks(generation int, tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) Cancel()
- func (e *Engine[KEY, T, W]) CancelAfter(interval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) Context() context.Context
- func (e *Engine[KEY, T, W]) ErrHandler(errHandler func(task *Task[KEY, T])) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) ErrHandlerRetryTimes(times int) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) ErrHandlerUtilSuccess() *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) ErrHandlerWriteToFile(path string) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) ExecTask(worker *Worker[KEY, T, W], task *Task[KEY, T])
- func (e *Engine[KEY, T, W]) KindGroupRandSpeedLimit(minInterval, maxInterval time.Duration, kinds ...Kind) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) KindGroupSpeedLimit(interval time.Duration, kinds ...Kind) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) KindLimiter(kind Kind, r rate.Limit, b int) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) KindRandSpeedLimit(kind Kind, minInterval, maxInterval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) KindSpeedLimit(kind Kind, interval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) Limiter(r rate.Limit, b int) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) MonitorInterval(interval time.Duration)
- func (e *Engine[KEY, T, W]) NewFixedWorker(interval time.Duration) int
- func (e *Engine[KEY, T, W]) RandSpeedLimited(minInterval, maxInterval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) Run(tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) RunSingleWorker(tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) SkipKind(kinds ...Kind) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) SpeedLimited(interval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) Stop()
- func (e *Engine[KEY, T, W]) StopAfter(interval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) StopCallBack(callBack func()) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) TaskSourceChannel(taskSourceChannel <-chan *Task[KEY, T])
- func (e *Engine[KEY, T, W]) TaskSourceFunc(taskSourceFunc func(*Engine[KEY, T, W]))
- type EngineStatistics
- type ErrHandle
- type Kind
- type KindHandler
- type Task
- type TaskFunc
- 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, T, W any] struct { WorkerCount uint }
type Engine ¶
type Engine[KEY comparable, T, W any] struct { EngineStatistics // contains filtered or unexported fields }
func NewEngineWithContext ¶
func (*Engine[KEY, T, W]) AddFixedTasks ¶
func (*Engine[KEY, T, W]) AddNoPriorityTasks ¶
func (*Engine[KEY, T, W]) AsyncAddTasks ¶
func (*Engine[KEY, T, W]) CancelAfter ¶
func (*Engine[KEY, T, W]) ErrHandler ¶
func (*Engine[KEY, T, W]) ErrHandlerRetryTimes ¶
func (*Engine[KEY, T, W]) ErrHandlerUtilSuccess ¶
func (*Engine[KEY, T, W]) ErrHandlerWriteToFile ¶
func (*Engine[KEY, T, W]) KindGroupRandSpeedLimit ¶
func (*Engine[KEY, T, W]) KindGroupSpeedLimit ¶
func (e *Engine[KEY, T, W]) KindGroupSpeedLimit(interval time.Duration, kinds ...Kind) *Engine[KEY, T, W]
多个kind共用一个timer
func (*Engine[KEY, T, W]) KindLimiter ¶
func (*Engine[KEY, T, W]) KindRandSpeedLimit ¶
func (*Engine[KEY, T, W]) KindSpeedLimit ¶
func (*Engine[KEY, T, W]) MonitorInterval ¶
func (*Engine[KEY, T, W]) NewFixedWorker ¶
func (*Engine[KEY, T, W]) RandSpeedLimited ¶
func (*Engine[KEY, T, W]) RunSingleWorker ¶
func (*Engine[KEY, T, W]) SpeedLimited ¶
func (*Engine[KEY, T, W]) StopCallBack ¶
func (*Engine[KEY, T, W]) TaskSourceChannel ¶
TaskSourceChannel 任务源,参数是一个channel,channel关闭时,代表任务源停止发送任务
func (*Engine[KEY, T, W]) TaskSourceFunc ¶
TaskSourceFunc,参数为添加任务的函数,直到该函数运行结束,任务引擎才会检测任务是否结束
type EngineStatistics ¶
type EngineStatistics struct { WorkStatistics // contains filtered or unexported fields }
EngineStatistics 基本引擎统计数据
type KindHandler ¶
type KindHandler[KEY comparable, T any] struct { Skip bool // TODO 指定Kind的Handler HandleFun TaskFunc[KEY, T] // contains filtered or unexported fields }
type Task ¶
type Task[KEY comparable, P any] struct { TaskMeta[KEY] TaskFunc[KEY, P] Props P // contains filtered or unexported fields }
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, P any] []*Task[KEY, P]
type WorkStatistics ¶
type WorkStatistics struct {
// contains filtered or unexported fields
}
WorkStatistics worker统计数据
Click to show internal directories.
Click to hide internal directories.