worker

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(conf *asynq.Config)

Option is a function, which configures the Worker.

func WithErrorHandler

func WithErrorHandler(handler asynq.ErrorHandler) Option

WithErrorHandler is an Option, which configures the Worker to use the specified asynq.ErrorHandler.

func WithLogLevel

func WithLogLevel(level asynq.LogLevel) Option

WithLogLevel is an Option, which configures the log level of the Worker.

type Worker

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

Worker wraps an asynq.Server and asynq.ServeMux with additional convenience methods for task handlers. It also provides an HTTP server, which serves worker-related metrics.

func NewFromConfig

func NewFromConfig(ctx context.Context, r asynq.RedisClientOpt, conf config.WorkerConfig, opts ...Option) *Worker

NewFromConfig creates a new Worker based on the provided config.WorkerConfig spec.

func (*Worker) Handle

func (w *Worker) Handle(pattern string, handler asynq.Handler)

Handle registers a new task handler with the Worker's multiplexer.

func (*Worker) HandlersFromRegistry

func (w *Worker) HandlersFromRegistry(reg *registry.Registry[string, asynq.Handler])

HandlersFromRegistry registers task handlers with the Worker multiplexer using the given registry.

func (*Worker) Run

func (w *Worker) Run() error

Run starts the task processing by calling asynq.Server.Start and blocks until an OS signal is received.

func (*Worker) Shutdown

func (w *Worker) Shutdown()

Shutdown gracefully shuts down the server by calling asynq.Server.Shutdown.

func (*Worker) UseMiddlewares

func (w *Worker) UseMiddlewares(middlewares ...asynq.MiddlewareFunc)

UseMiddlewares configures the Worker multiplexer to use the specified asynq.MiddlewareFunc.

Jump to

Keyboard shortcuts

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