worker

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHandlerNotFound = errors.New("handler not found for job type")
	ErrHandlerExists   = errors.New("handler already registered for job type")
)

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc func(ctx context.Context, j *job.Job) error

type Middleware

type Middleware func(next HandlerFunc) HandlerFunc

func Chain

func Chain(middleware ...Middleware) Middleware

type Pool

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

func NewPool

func NewPool(b broker.Broker, registry *Registry, opts ...PoolOption) *Pool

func (*Pool) IsRunning

func (p *Pool) IsRunning() bool

func (*Pool) MustRegisterHandler

func (p *Pool) MustRegisterHandler(jobType string, handler HandlerFunc)

func (*Pool) Queues

func (p *Pool) Queues() []string

func (*Pool) RegisterHandler

func (p *Pool) RegisterHandler(jobType string, handler HandlerFunc) error

func (*Pool) Start

func (p *Pool) Start(ctx context.Context) error

func (*Pool) Stop

func (p *Pool) Stop(ctx context.Context) error

func (*Pool) Use

func (p *Pool) Use(mw ...Middleware)

func (*Pool) WorkerCount

func (p *Pool) WorkerCount() int

type PoolOption

type PoolOption func(*Pool)

func WithConcurrency

func WithConcurrency(n int) PoolOption

func WithPoolLogger

func WithPoolLogger(logger zerolog.Logger) PoolOption

func WithPoolPollInterval

func WithPoolPollInterval(d time.Duration) PoolOption

func WithPoolQueues

func WithPoolQueues(queues []string) PoolOption

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) PoolOption

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Clear

func (r *Registry) Clear()

func (*Registry) Get

func (r *Registry) Get(jobType string) (HandlerFunc, error)

func (*Registry) Has

func (r *Registry) Has(jobType string) bool

func (*Registry) MustRegister

func (r *Registry) MustRegister(jobType string, handler HandlerFunc)

func (*Registry) Register

func (r *Registry) Register(jobType string, handler HandlerFunc) error

func (*Registry) Types

func (r *Registry) Types() []string

func (*Registry) Unregister

func (r *Registry) Unregister(jobType string)

func (*Registry) Use

func (r *Registry) Use(mw ...Middleware)

type Worker

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

func NewWorker

func NewWorker(id string, b broker.Broker, registry *Registry, opts ...WorkerOption) *Worker

func (*Worker) ID

func (w *Worker) ID() string

func (*Worker) Run

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

type WorkerOption

type WorkerOption func(*Worker)

func WithLogger

func WithLogger(logger zerolog.Logger) WorkerOption

func WithPollInterval

func WithPollInterval(d time.Duration) WorkerOption

func WithQueues

func WithQueues(queues []string) WorkerOption

Jump to

Keyboard shortcuts

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