queue

package
v0.0.1-dev.10 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQueueFull         = errors.New("queue is full")
	ErrQueueEmpty        = errors.New("queue is empty")
	ErrTaskNotFound      = errors.New("task not found")
	ErrTaskNotReady      = errors.New("task is not ready for execution")
	ErrRateLimitExceeded = errors.New("rate limit exceeded")
	ErrBatchNotReady     = errors.New("batch is not ready for processing")
)

Error definitions

Functions

func NewBatchQueue

func NewBatchQueue(queue Queue, batchSize, capacity int) *batchQueue

NewBatchQueue creates a new batch queue

func NewDelayedQueue

func NewDelayedQueue(capacity int) *delayedQueue

NewDelayedQueue creates a new delayed queue

func NewFIFOQueue

func NewFIFOQueue(capacity int) *fifoQueue

NewFIFOQueue creates a new FIFO queue

func NewPriorityQueue

func NewPriorityQueue(capacity int) *priorityQueue

NewPriorityQueue creates a new priority queue

func NewRateLimitQueue

func NewRateLimitQueue(queue Queue, rate time.Duration, capacity int) *rateLimitQueue

NewRateLimitQueue creates a new rate-limited queue

Types

type DeadLetterQueue

type DeadLetterQueue struct {
	// contains filtered or unexported fields
}

DeadLetterQueue implements a queue for permanently failed tasks

func NewDeadLetterQueue

func NewDeadLetterQueue(capacity int) *DeadLetterQueue

NewDeadLetterQueue creates a new dead letter queue

func (*DeadLetterQueue) Add

func (q *DeadLetterQueue) Add(ctx context.Context, task worker.Task) error

Add adds a task to the dead letter queue

func (*DeadLetterQueue) Clear

func (q *DeadLetterQueue) Clear(ctx context.Context) error

Clear removes all tasks from the queue

func (*DeadLetterQueue) Get

Get retrieves a task from the dead letter queue (FIFO)

func (*DeadLetterQueue) List

func (q *DeadLetterQueue) List(ctx context.Context) ([]worker.Task, error)

List returns all tasks in the dead letter queue for inspection

func (*DeadLetterQueue) Peek

func (q *DeadLetterQueue) Peek(ctx context.Context) (worker.Task, error)

Peek returns the next task without removing it

func (*DeadLetterQueue) Remove

func (q *DeadLetterQueue) Remove(ctx context.Context, taskID string) error

Remove removes a specific task from the queue

func (*DeadLetterQueue) Size

func (q *DeadLetterQueue) Size(ctx context.Context) (int, error)

Size returns the number of tasks in the queue

type Queue

type Queue interface {
	// Add adds a task to the queue
	Add(ctx context.Context, task worker.Task) error

	// Get retrieves the next task from the queue
	Get(ctx context.Context) (worker.Task, error)

	// Remove removes a task from the queue
	Remove(ctx context.Context, taskID string) error

	// Size returns the number of tasks in the queue
	Size(ctx context.Context) (int, error)

	// Clear removes all tasks from the queue
	Clear(ctx context.Context) error
}

Queue defines the interface for task queues

type QueueType

type QueueType string

QueueType represents the type of queue

const (
	QueueTypePriority   QueueType = "priority"
	QueueTypeDelayed    QueueType = "delayed"
	QueueTypeDeadLetter QueueType = "dead_letter"
	QueueTypeRateLimit  QueueType = "rate_limit"
	QueueTypeBatch      QueueType = "batch"
	QueueTypeFIFO       QueueType = "fifo"
)

Jump to

Keyboard shortcuts

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