task

package
v0.0.50-alpha.103 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGlobalQueueFull     = errors.New("global queue is full")
	ErrWaitingQueueFull    = errors.New("waiting queue is full")
	ErrProcessingQueueFull = errors.New("processing queue is full")
	ErrDataNotFound        = errors.New("data not found")
)

Functions

This section is empty.

Types

type QueueManager

type QueueManager[T any, K comparable] interface {
	// AddKey adds a new key to the queue manager
	AddKey(ctx context.Context, key K) error

	// Insert inserts data into the queue, automatically assigning a key based on the strategy
	// Returns the assigned key (empty string if queued in global queue)
	Insert(ctx context.Context, data T) (K, error)

	// InsertByKey inserts data into the queue for a specific key
	InsertByKey(ctx context.Context, key K, data T) error

	// Delete removes data from the specified key's queue
	Delete(ctx context.Context, key K, data T) error

	// DeleteKey removes a key and its associated queue
	DeleteKey(ctx context.Context, key K) error

	// GetProcessingQueueLengths returns the length of processing queue for each key
	GetProcessingQueueLengths(ctx context.Context) (map[K]int, error)

	// TransformProcessingData moves data from one key's processing queue to another
	TransformProcessingData(ctx context.Context, fromKey, toKey K, data T) error

	// AutoTransformProcessingData moves data from one key's processing queue to another key selected by strategy
	// Returns the selected target key
	AutoTransformProcessingData(ctx context.Context, fromKey K, data T) (K, error)

	// GetGlobalQueuePosition returns the position of data in the global queue (0-based, -1 if not found)
	GetGlobalQueuePosition(ctx context.Context, data T) (int, error)
}

QueueManager defines the interface for managing task queues

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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