Documentation
¶
Overview ¶
Package queue provides a channel-based queue implementation and job processing utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosedQueue = errors.New("queue is closed")
ErrClosedQueue is returned when attempting to operate on a closed queue.
var ErrTimeout = errors.New("timeout")
ErrTimeout is returned when an enqueue operation times out.
Functions ¶
This section is empty.
Types ¶
type ChanQueue ¶
type ChanQueue[T any] struct { // contains filtered or unexported fields }
ChanQueue is a thread-safe channel-based queue implementation.
func NewChanQueue ¶
NewChanQueue creates a new channel-based queue with the specified buffer size and enqueue timeout.
func (*ChanQueue[T]) EnqueueJob ¶
EnqueueJob adds a job to the queue with timeout support.
func (*ChanQueue[T]) GetJobChan ¶
GetJobChan returns the underlying channel for reading jobs.
type HandlerFunc ¶
HandlerFunc is an adapter to allow the use of ordinary functions as Handlers.
func (HandlerFunc[T]) Handle ¶
func (f HandlerFunc[T]) Handle(ctx context.Context, job T)
Handle calls f(ctx, job).
type Processor ¶
type Processor[T any] struct { // contains filtered or unexported fields }
Processor manages a pool of workers to process jobs from a queue.
func New ¶
func New[T any](handler Handler[T], queue Provider[T], workersAmount int, shutdownTimeout time.Duration) *Processor[T]
New creates a new Processor with the specified handler, queue, and configuration.