Documentation ¶
Index ¶
- Constants
- func ReTry(times int, f func() error)
- type BaseEngine
- func (e *BaseEngine[KEY, T, W]) AddFixedTask(workerId int, task *BaseTask[KEY, T])
- func (e *BaseEngine[KEY, T, W]) AddTask(task *BaseTask[KEY, T])
- func (e *BaseEngine[KEY, T, W]) AddTasks(tasks ...*BaseTask[KEY, T])
- func (e *BaseEngine[KEY, T, W]) AddWorker(num int)
- func (e *BaseEngine[KEY, T, W]) Cancel()
- func (e *BaseEngine[KEY, T, W]) Context() context.Context
- func (e *BaseEngine[KEY, T, W]) MonitorInterval(interval time.Duration)
- func (e *BaseEngine[KEY, T, W]) NewFixedWorker(interval time.Duration) int
- func (e *BaseEngine[KEY, T, W]) RandSpeedLimited(start, stop time.Duration)
- func (e *BaseEngine[KEY, T, W]) Release()
- func (e *BaseEngine[KEY, T, W]) Run(tasks ...*BaseTask[KEY, T])
- func (e *BaseEngine[KEY, T, W]) RunSingleWorker(tasks ...*BaseTask[KEY, T])
- func (e *BaseEngine[KEY, T, W]) SpeedLimited(interval time.Duration)
- func (e *BaseEngine[KEY, T, W]) SyncRun(tasks ...*BaseTask[KEY, T])
- type BaseTask
- type BaseTaskFunc
- type BaseTaskMeta
- type Controller
- type Engine
- func (e *Engine[KEY, T, W]) AddFixedTask(workerId int, task *Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddTask(task *Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddTasks(generation int, tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddTasksWrapper(generation int, tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) AsyncAddTask(generation int, tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) BaseTask(task *Task[KEY, T]) *BaseTask[KEY, T]
- func (e *Engine[KEY, T, W]) ErrHandler(errHandler func(task *Task[KEY, T])) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) KindGroupTimer(interval time.Duration, kinds ...Kind) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) Limiter(kind Kind, r rate.Limit, b int) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) ReRun(tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) Release()
- 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]) StopAfter(interval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) Timer(kind Kind, interval time.Duration) *Engine[KEY, T, W]
- type EngineStatistics
- type ErrHandle
- type Kind
- type KindConfig
- type KindEngine
- type KindHandler
- type SchedulingContext
- type Task
- type TaskFunc
- type TaskMeta
- type TaskStatistics
- type Tasks
- type WorkStatistics
- type Worker
Constants ¶
View Source
const (
KindNormal = iota
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseEngine ¶
type BaseEngine[KEY comparable, T, W any] struct { EngineStatistics // contains filtered or unexported fields }
func NewBaseEngine ¶
func NewBaseEngine[KEY comparable, T, W any](workerCount uint) *BaseEngine[KEY, T, W]
func NewBaseEngineWithContext ¶
func NewBaseEngineWithContext[KEY comparable, T, W any](workerCount uint, ctx context.Context) *BaseEngine[KEY, T, W]
func (*BaseEngine[KEY, T, W]) AddFixedTask ¶
func (e *BaseEngine[KEY, T, W]) AddFixedTask(workerId int, task *BaseTask[KEY, T])
func (*BaseEngine[KEY, T, W]) AddTask ¶
func (e *BaseEngine[KEY, T, W]) AddTask(task *BaseTask[KEY, T])
func (*BaseEngine[KEY, T, W]) AddTasks ¶
func (e *BaseEngine[KEY, T, W]) AddTasks(tasks ...*BaseTask[KEY, T])
func (*BaseEngine[KEY, T, W]) AddWorker ¶
func (e *BaseEngine[KEY, T, W]) AddWorker(num int)
func (*BaseEngine[KEY, T, W]) Cancel ¶
func (e *BaseEngine[KEY, T, W]) Cancel()
func (*BaseEngine[KEY, T, W]) Context ¶
func (e *BaseEngine[KEY, T, W]) Context() context.Context
func (*BaseEngine[KEY, T, W]) MonitorInterval ¶
func (e *BaseEngine[KEY, T, W]) MonitorInterval(interval time.Duration)
func (*BaseEngine[KEY, T, W]) NewFixedWorker ¶
func (e *BaseEngine[KEY, T, W]) NewFixedWorker(interval time.Duration) int
func (*BaseEngine[KEY, T, W]) RandSpeedLimited ¶
func (e *BaseEngine[KEY, T, W]) RandSpeedLimited(start, stop time.Duration)
func (*BaseEngine[KEY, T, W]) Release ¶
func (e *BaseEngine[KEY, T, W]) Release()
func (*BaseEngine[KEY, T, W]) Run ¶
func (e *BaseEngine[KEY, T, W]) Run(tasks ...*BaseTask[KEY, T])
func (*BaseEngine[KEY, T, W]) RunSingleWorker ¶
func (e *BaseEngine[KEY, T, W]) RunSingleWorker(tasks ...*BaseTask[KEY, T])
func (*BaseEngine[KEY, T, W]) SpeedLimited ¶
func (e *BaseEngine[KEY, T, W]) SpeedLimited(interval time.Duration)
func (*BaseEngine[KEY, T, W]) SyncRun ¶
func (e *BaseEngine[KEY, T, W]) SyncRun(tasks ...*BaseTask[KEY, T])
type BaseTask ¶
type BaseTask[KEY comparable, T any] struct { BaseTaskMeta[KEY] BaseTaskFunc Props T }
type BaseTaskFunc ¶
type BaseTaskMeta ¶
type BaseTaskMeta[KEY comparable] struct { Key KEY Describe string Priority int // contains filtered or unexported fields }
func (*BaseTaskMeta[KEY]) CmpKey ¶
func (t *BaseTaskMeta[KEY]) CmpKey() int
func (*BaseTaskMeta[KEY]) SetPriority ¶
func (t *BaseTaskMeta[KEY]) SetPriority(priority int)
type Controller ¶
type Controller chan func() error
func (Controller) AddTask ¶
func (c Controller) AddTask(f func() error)
func (Controller) Start ¶
func (c Controller) Start()
type Engine ¶
type Engine[KEY comparable, T, W any] struct { *BaseEngine[KEY, T, W] // contains filtered or unexported fields }
func (*Engine[KEY, T, W]) AddFixedTask ¶
func (*Engine[KEY, T, W]) AddTasksWrapper ¶
IDEA的bug,可以编译过去,但是报错,提示方法是嵌套结构体的方法,为了跳转写的包装方法
func (*Engine[KEY, T, W]) AsyncAddTask ¶
func (*Engine[KEY, T, W]) ErrHandler ¶
func (*Engine[KEY, T, W]) KindGroupTimer ¶
func (e *Engine[KEY, T, W]) KindGroupTimer(interval time.Duration, kinds ...Kind) *Engine[KEY, T, W]
多个kind共用一个timer
func (*Engine[KEY, T, W]) RunSingleWorker ¶
type EngineStatistics ¶
type EngineStatistics = WorkStatistics
type KindConfig ¶
type KindConfig[KEY comparable, T, W any] struct { // contains filtered or unexported fields }
type KindEngine ¶
type KindEngine[KEY comparable, T, W any] struct { // contains filtered or unexported fields }
TODO
func (*KindEngine[KEY, T, W]) Run ¶
func (e *KindEngine[KEY, T, W]) Run()
type KindHandler ¶
type SchedulingContext ¶
type SchedulingContext struct { context.Context Done bool // contains filtered or unexported fields }
func (*SchedulingContext) Monitor ¶
func (c *SchedulingContext) Monitor() func()
type Task ¶
type Task[KEY comparable, P any] struct { TaskMeta[KEY] TaskFunc[KEY, P] Props P // contains filtered or unexported fields }
func AnonymousTask ¶
func AnonymousTask[KEY comparable, T any](fun BaseTaskFunc) *Task[KEY, T]
type TaskMeta ¶
type TaskMeta[KEY comparable] struct { BaseTaskMeta[KEY] Kind Kind TaskStatistics }
TODO
type TaskStatistics ¶
type TaskStatistics struct { ErrTimes int // 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
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.