Documentation ¶
Index ¶
- func ScanTQueueBySubKey(queue TQueue, subKey task.TKey) ([]task.Task, error)
- func ScanTQueueWithLimitBySubKey(queue TQueueWithLimit, subKey task.TKey) ([]task.Task, error)
- type NewTQueue
- type NewTQueueOnStrategy
- type NewTQueueOnStrategyWithLimit
- type NewTQueueWithLimit
- type NilQueue
- func (*NilQueue) Cap() int
- func (*NilQueue) Has(task.TKey) bool
- func (*NilQueue) Len() int
- func (*NilQueue) Pop() task.Task
- func (*NilQueue) PopByKey(task.TKey) task.Task
- func (*NilQueue) PopByLimit(rcmgr.Limit) task.Task
- func (*NilQueue) Push(task.Task) error
- func (*NilQueue) ScanTask(func(task.Task))
- func (*NilQueue) SetFilterTaskStrategy(func(task.Task) bool)
- func (*NilQueue) SetRetireTaskStrategy(func(task.Task) bool)
- func (*NilQueue) Top() task.Task
- func (*NilQueue) TopByLimit(rcmgr.Limit) task.Task
- type TQueue
- type TQueueOnStrategy
- type TQueueOnStrategyWithLimit
- type TQueueStrategy
- type TQueueWithLimit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScanTQueueBySubKey ¶
Types ¶
type NewTQueueOnStrategy ¶
type NewTQueueOnStrategy = func(name string, cap int) TQueueOnStrategy
NewTQueueOnStrategy defines the new func type of TQueueOnStrategy
type NewTQueueOnStrategyWithLimit ¶
type NewTQueueOnStrategyWithLimit = func(name string, cap int) TQueueOnStrategyWithLimit
NewTQueueOnStrategyWithLimit the new func type of TQueueOnStrategyWithLimit
type NewTQueueWithLimit ¶
type NewTQueueWithLimit = func(name string, cap int) TQueueWithLimit
NewTQueueWithLimit defines the new func type of TQueueWithLimit
type NilQueue ¶
type NilQueue struct{}
func (*NilQueue) SetFilterTaskStrategy ¶
func (*NilQueue) SetRetireTaskStrategy ¶
type TQueue ¶
type TQueue interface { // Top returns the top task in the queue, if the queue empty, returns nil. Top() task.Task // Pop pops and returns the top task in queue, if the queue empty, returns nil. Pop() task.Task // PopByKey pops the task by the task key, if the task does not exist , returns nil. PopByKey(task.TKey) task.Task // Has returns an indicator whether the task in queue. Has(task.TKey) bool // Push pushes the task in queue tail, if the queue len greater the capacity, returns error. Push(task.Task) error // Len returns the length of queue. Len() int // Cap returns the capacity of queue. Cap() int // ScanTask scans all tasks, and call the func one by one task. ScanTask(func(task.Task)) }
TQueue is the interface to task queue. The task queue is mainly used to maintain tasks are running. In addition to supporting conventional FIFO operations, task queue also has some customized operations for task. For example, Has, PopByKey.
type TQueueOnStrategy ¶
type TQueueOnStrategy interface { TQueue TQueueStrategy }
TQueueOnStrategy is the interface to task queue and the queue supports customize strategies to filter task for popping and retiring task.
type TQueueOnStrategyWithLimit ¶
type TQueueOnStrategyWithLimit interface { TQueueWithLimit TQueueStrategy }
TQueueOnStrategyWithLimit is the interface to task queue that takes resources into account, and the queue supports customize strategies to filter task for popping and retiring task.
type TQueueStrategy ¶
type TQueueStrategy interface { // SetFilterTaskStrategy sets the callback func to filter task for popping or topping. SetFilterTaskStrategy(func(task.Task) bool) // SetRetireTaskStrategy sets the callback func to retire task, when the queue is full, it will be // called to retire tasks. SetRetireTaskStrategy(func(task.Task) bool) }
TQueueStrategy is the interface to queue customize strategies, it supports filter task for popping and retiring task strategies.
type TQueueWithLimit ¶
type TQueueWithLimit interface { // TopByLimit returns the top task that the LimitEstimate less than the param in the queue. TopByLimit(rcmgr.Limit) task.Task // PopByLimit pops and returns the top task that the LimitEstimate less than the param in the queue. PopByLimit(rcmgr.Limit) task.Task // PopByKey pops the task by the task key, if the task does not exist , returns nil. PopByKey(task.TKey) task.Task // Has returns an indicator whether the task in queue. Has(task.TKey) bool // Push pushes the task in queue tail, if the queue len greater the capacity, returns error. Push(task.Task) error // Len returns the length of queue. Len() int // Cap returns the capacity of queue. Cap() int // ScanTask scans all tasks, and call the func one by one task. ScanTask(func(task.Task)) }
TQueueWithLimit is the interface task queue that takes resources into account. Only tasks with less than required resources can be popped out.