handlers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package handlers provides the task handler registry for the scheduler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc func(context.Context, *asynq.Task) error

HandlerFunc is a function that handles an Asynq task.

type MiddlewareFunc

type MiddlewareFunc func(HandlerFunc) HandlerFunc

MiddlewareFunc is middleware for task handlers.

func LoggingMiddleware

func LoggingMiddleware(logFn func(format string, args ...any)) MiddlewareFunc

LoggingMiddleware creates a middleware that logs task execution.

func RecoveryMiddleware

func RecoveryMiddleware(logFn func(format string, args ...any)) MiddlewareFunc

RecoveryMiddleware creates a middleware that recovers from panics.

func TimeoutMiddleware

func TimeoutMiddleware(logFn func(format string, args ...any)) MiddlewareFunc

TimeoutMiddleware creates a middleware that enforces task timeout. Note: Asynq already handles timeouts, this is for additional logging.

type Registry

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

Registry manages task handlers.

func NewEmptyRegistry

func NewEmptyRegistry() *Registry

NewEmptyRegistry creates an empty handler registry.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new handler registry with default handlers.

func (*Registry) Get

func (r *Registry) Get(taskType string) (HandlerFunc, bool)

Get returns the handler for the given task type.

func (*Registry) GetMux

func (r *Registry) GetMux() *asynq.ServeMux

GetMux returns an Asynq ServeMux configured with all registered handlers.

func (*Registry) Has

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

Has checks if a handler is registered for the given task type.

func (*Registry) ListTypes

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

ListTypes returns all registered task types.

func (*Registry) Register

func (r *Registry) Register(taskType string, handler HandlerFunc)

Register adds a handler for the given task type.

func (*Registry) Unregister

func (r *Registry) Unregister(taskType string)

Unregister removes a handler for the given task type.

func (*Registry) WithMiddleware

func (r *Registry) WithMiddleware(middleware ...MiddlewareFunc)

WithMiddleware wraps all handlers with the given middleware.

Jump to

Keyboard shortcuts

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