Documentation ¶
Index ¶
- Constants
- func ReTry(times int, f func() error) error
- type BaseEngine
- func (e *BaseEngine[KEY, T, W]) AddFixedTask(workerId int, task *BaseTask[KEY, T]) error
- 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 BaseEngineStatistics
- type BaseTask
- type BaseTaskFunc
- type BaseTaskMeta
- type Controller
- type Engine
- func (e *Engine[KEY, T, W]) AddFixedTask(workerId int, task *Task[KEY, T]) error
- func (e *Engine[KEY, T, W]) AddNoPriorityTask(task *Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddNoPriorityTasks(tasks ...*Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddTask(generation int, task *Task[KEY, T])
- func (e *Engine[KEY, T, W]) AddTasks(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]) ErrHandlerUtilSuccess() *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]) SourceTask(task func(*Engine[KEY, T, W]))
- func (e *Engine[KEY, T, W]) StopAfter(interval time.Duration) *Engine[KEY, T, W]
- func (e *Engine[KEY, T, W]) TaskSource(source <-chan *Task[KEY, T])
- 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 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 { BaseEngineStatistics // 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]) error
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 BaseEngineStatistics ¶ added in v1.1.0
type BaseEngineStatistics = WorkStatistics
BaseEngineStatistics 基本引擎统计数据
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]) OrderKey ¶ added in v1.1.0
func (t *BaseTaskMeta[KEY]) OrderKey() 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] EngineStatistics // contains filtered or unexported fields }
func (*Engine[KEY, T, W]) AddFixedTask ¶
func (*Engine[KEY, T, W]) AddNoPriorityTask ¶ added in v1.1.0
func (*Engine[KEY, T, W]) AddNoPriorityTasks ¶ added in v1.1.0
func (*Engine[KEY, T, W]) AsyncAddTask ¶
func (*Engine[KEY, T, W]) ErrHandler ¶
func (*Engine[KEY, T, W]) ErrHandlerUtilSuccess ¶ added in v1.1.0
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 ¶
func (*Engine[KEY, T, W]) SourceTask ¶ added in v1.1.0
func (*Engine[KEY, T, W]) TaskSource ¶ added in v1.1.0
TaskSource 任务源,参数是一个channel,channel关闭时,代表任务源停止发送任务
type EngineStatistics ¶
type EngineStatistics struct {
// contains filtered or unexported fields
}
引擎统计数据
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 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
}
WorkStatistics worker统计数据
Source Files ¶
Click to show internal directories.
Click to hide internal directories.