queue

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PriorityLow    = 0
	PriorityNormal = 1
	PriorityHigh   = 2
)

Variables

View Source
var (
	ErrClosed  = Error("queue closed")
	ErrFull    = Error("queue is full")
	ErrEmpty   = Error("queue is empty")
	ErrCleared = Error("queue was cleared")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxSize    int
	MaxPending int
	Timeout    time.Duration
}

func DefaultConfig

func DefaultConfig() *Config

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Interface

type Interface interface {
	Enqueue(ctx context.Context, content string, priority Priority) (<-chan *Result, error)
	EnqueueBatch(ctx context.Context, items []string, priority Priority) ([]<-chan *Result, error)
	OutputChan() <-chan *Item
	Complete(item *Item, result *Result)
	Size() int
	Pending() int
	GetStats() Stats
	Clear()
	Close()
}

func New

func New(cfg *Config) Interface

type Item

type Item struct {
	ID        string
	Content   string
	Priority  Priority
	CreatedAt time.Time
	Ch        chan *Result
}

type Priority

type Priority int

type Result

type Result struct {
	Output   string
	Error    error
	Duration time.Duration
}

type Stats

type Stats struct {
	Size           int           `json:"size"`
	Pending        int           `json:"pending"`
	TotalEnqueued  int64         `json:"total_enqueued"`
	TotalProcessed int64         `json:"total_processed"`
	AvgWaitTime    time.Duration `json:"avg_wait_time"`
}

Jump to

Keyboard shortcuts

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