Documentation ¶
Index ¶
- Constants
- Variables
- func NewGfSpTQueue(name string, cap int) taskqueue.TQueueOnStrategy
- func NewGfSpTQueueWithLimit(name string, cap int) taskqueue.TQueueOnStrategyWithLimit
- type GfSpTQueue
- func (t *GfSpTQueue) Cap() int
- func (t *GfSpTQueue) Has(key coretask.TKey) bool
- func (t *GfSpTQueue) Len() int
- func (t *GfSpTQueue) Pop() coretask.Task
- func (t *GfSpTQueue) PopByKey(key coretask.TKey) coretask.Task
- func (t *GfSpTQueue) Push(task coretask.Task) error
- func (t *GfSpTQueue) ScanTask(scan func(coretask.Task))
- func (t *GfSpTQueue) SetFilterTaskStrategy(filter func(coretask.Task) bool)
- func (t *GfSpTQueue) SetRetireTaskStrategy(retire func(coretask.Task) bool)
- func (t *GfSpTQueue) Top() coretask.Task
- type GfSpTQueueWithLimit
- func (t *GfSpTQueueWithLimit) Cap() int
- func (t *GfSpTQueueWithLimit) Has(key coretask.TKey) bool
- func (t *GfSpTQueueWithLimit) Len() int
- func (t *GfSpTQueueWithLimit) PopByKey(key coretask.TKey) coretask.Task
- func (t *GfSpTQueueWithLimit) PopByLimit(limit corercmgr.Limit) coretask.Task
- func (t *GfSpTQueueWithLimit) Push(task coretask.Task) error
- func (t *GfSpTQueueWithLimit) ScanTask(scan func(coretask.Task))
- func (t *GfSpTQueueWithLimit) SetFilterTaskStrategy(filter func(coretask.Task) bool)
- func (t *GfSpTQueueWithLimit) SetRetireTaskStrategy(retire func(coretask.Task) bool)
- func (t *GfSpTQueueWithLimit) TopByLimit(limit corercmgr.Limit) coretask.Task
Constants ¶
const (
TaskQueue = "TaskQueue"
)
Variables ¶
var ( ErrTaskRepeated = gfsperrors.Register(TaskQueue, http.StatusBadRequest, 970001, "request repeated") ErrTaskQueueExceed = gfsperrors.Register(TaskQueue, http.StatusBadRequest, 970002, "request exceed limit") )
Functions ¶
func NewGfSpTQueue ¶
func NewGfSpTQueue(name string, cap int) taskqueue.TQueueOnStrategy
func NewGfSpTQueueWithLimit ¶
func NewGfSpTQueueWithLimit(name string, cap int) taskqueue.TQueueOnStrategyWithLimit
Types ¶
type GfSpTQueue ¶
type GfSpTQueue struct {
// contains filtered or unexported fields
}
func (*GfSpTQueue) Has ¶
func (t *GfSpTQueue) Has(key coretask.TKey) bool
Has returns an indicator whether the task in queue.
func (*GfSpTQueue) Pop ¶
func (t *GfSpTQueue) Pop() coretask.Task
Pop pops and returns the top task in queue, if the queue empty, returns nil.
func (*GfSpTQueue) PopByKey ¶
func (t *GfSpTQueue) PopByKey(key coretask.TKey) coretask.Task
PopByKey pops the task by the task key, if the task does not exist , returns nil.
func (*GfSpTQueue) Push ¶
func (t *GfSpTQueue) Push(task coretask.Task) error
Push pushes the task in queue tail, if the queue len greater the capacity, returns error.
func (*GfSpTQueue) ScanTask ¶
func (t *GfSpTQueue) ScanTask(scan func(coretask.Task))
ScanTask scans all tasks, and call the func one by one task.
func (*GfSpTQueue) SetFilterTaskStrategy ¶
func (t *GfSpTQueue) SetFilterTaskStrategy(filter func(coretask.Task) bool)
SetFilterTaskStrategy sets the callback func to filter task for popping or topping.
func (*GfSpTQueue) SetRetireTaskStrategy ¶
func (t *GfSpTQueue) SetRetireTaskStrategy(retire func(coretask.Task) bool)
SetRetireTaskStrategy sets the callback func to retire task, when the queue is full, it will be called to retire tasks.
func (*GfSpTQueue) Top ¶
func (t *GfSpTQueue) Top() coretask.Task
Top returns the top task in the queue, if the queue empty, returns nil.
type GfSpTQueueWithLimit ¶
type GfSpTQueueWithLimit struct {
// contains filtered or unexported fields
}
func (*GfSpTQueueWithLimit) Cap ¶
func (t *GfSpTQueueWithLimit) Cap() int
Cap returns the capacity of queue.
func (*GfSpTQueueWithLimit) Has ¶
func (t *GfSpTQueueWithLimit) Has(key coretask.TKey) bool
Has returns an indicator whether the task in queue.
func (*GfSpTQueueWithLimit) Len ¶
func (t *GfSpTQueueWithLimit) Len() int
Len returns the length of queue.
func (*GfSpTQueueWithLimit) PopByKey ¶
func (t *GfSpTQueueWithLimit) PopByKey(key coretask.TKey) coretask.Task
PopByKey pops the task by the task key, if the task does not exist , returns nil.
func (*GfSpTQueueWithLimit) PopByLimit ¶
func (t *GfSpTQueueWithLimit) PopByLimit(limit corercmgr.Limit) coretask.Task
PopByLimit pops and returns the top task that the LimitEstimate less than the param in the queue.
func (*GfSpTQueueWithLimit) Push ¶
func (t *GfSpTQueueWithLimit) Push(task coretask.Task) error
Push pushes the task in queue tail, if the queue len greater the capacity, returns error.
func (*GfSpTQueueWithLimit) ScanTask ¶
func (t *GfSpTQueueWithLimit) ScanTask(scan func(coretask.Task))
ScanTask scans all tasks, and call the func one by one task.
func (*GfSpTQueueWithLimit) SetFilterTaskStrategy ¶
func (t *GfSpTQueueWithLimit) SetFilterTaskStrategy(filter func(coretask.Task) bool)
SetFilterTaskStrategy sets the callback func to filter task for popping or topping.
func (*GfSpTQueueWithLimit) SetRetireTaskStrategy ¶
func (t *GfSpTQueueWithLimit) SetRetireTaskStrategy(retire func(coretask.Task) bool)
SetRetireTaskStrategy sets the callback func to retire task, when the queue is full, it will be called to retire tasks.
func (*GfSpTQueueWithLimit) TopByLimit ¶
func (t *GfSpTQueueWithLimit) TopByLimit(limit corercmgr.Limit) coretask.Task