Documentation
¶
Index ¶
Constants ¶
View Source
const (
Least strategy = iota + 1
)
Variables ¶
Functions ¶
func LeastTask ¶
func LeastTask[T any, K comparable](tm *QueueManager[T, K]) (K, bool)
LeastTask : return key witch has the least tasks
Types ¶
type Options ¶
type Options[T any, K comparable] func(*QueueManager[T, K])
func WithAfterProcessPushFunc ¶
func WithAfterProcessPushFunc[T any, K comparable](fs ...func(key K, data T)) Options[T, K]
func WithStrategy ¶
func WithStrategy[T any, K comparable](s strategy) Options[T, K]
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue will pop data from its waiting Queue. If it`s empty, it will pop data from global Queue(in QueueManager), and then push to process Queue.
type QueueManager ¶
type QueueManager[T any, K comparable] struct { // contains filtered or unexported fields }
func NewQueueManager ¶
func NewQueueManager[T any, K comparable]( maxGlobal, maxProcessing, maxWaiting int, equalFunc func(a, b T) bool, opts ...Options[T, K], ) *QueueManager[T, K]
func (*QueueManager[T, K]) Delete ¶
func (tm *QueueManager[T, K]) Delete(key K, data T) error
Delete will delete a data in key queues. If delete a data in processing Queue, taskQueue will pop data from its waiting Queue. If it`s empty, it will pop data from global Queue, and then push to process Queue.
func (*QueueManager[T, K]) GetProcessingQueueLengths ¶
func (tm *QueueManager[T, K]) GetProcessingQueueLengths() map[K]int
func (*QueueManager[T, K]) Insert ¶
func (tm *QueueManager[T, K]) Insert(data T) error
func (*QueueManager[T, K]) InsertByKey ¶
func (tm *QueueManager[T, K]) InsertByKey(key K, data T) error
Click to show internal directories.
Click to hide internal directories.