gfsptqueue

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskQueue = "TaskQueue"
)

Variables

View Source
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) Cap

func (t *GfSpTQueue) Cap() int

Cap returns the capacity of queue.

func (*GfSpTQueue) Has

func (t *GfSpTQueue) Has(key coretask.TKey) bool

Has returns an indicator whether the task in queue.

func (*GfSpTQueue) Len

func (t *GfSpTQueue) Len() int

Len returns the length of 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL