worker

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package worker provides job processing functionality through concurrent worker goroutines. It handles job execution, retries, error recovery, and graceful shutdown while maintaining configurable concurrency limits and collecting performance metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Worker

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

Worker manages a pool of goroutines that process jobs from a queue. It handles job execution, retries, metrics collection, and graceful shutdown.

func NewWorker

func NewWorker(store adapter.Store, config configuration.Config, queueName string, statsCollector *stats.Collector, logger logger.Logger) *Worker

NewWorker creates a new Worker instance with the specified configuration. It initializes the middleware chain, concurrency controls, and metrics collection.

func (*Worker) Shutdown

func (w *Worker) Shutdown(ctx context.Context) error

Shutdown initiates a graceful shutdown of all worker goroutines. It prevents workers from picking up new jobs and waits for in-progress jobs to complete, up to the context's deadline.

func (*Worker) Start

func (w *Worker) Start(ctx context.Context, noOfWorkers int) error

Start launches the specified number of worker goroutines to process jobs. It returns an error if the driver is unsupported or if the requested number of workers exceeds the configured maximum.

Jump to

Keyboard shortcuts

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