asynq

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package asynq provides various asynq utilities

Package asynq provides various asynq utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enqueue added in v0.1.9

func Enqueue(ctx context.Context, items []TaskConstructor, opts ...asynq.Option) error

Enqueue enqueues the tasks produced by the given task constructors.

func GetLogger

func GetLogger(ctx context.Context) *slog.Logger

GetLogger returns the slog.Logger instance from the provided context, if found, or slog.DefaultLogger otherwise.

func GetQueueName added in v0.1.8

func GetQueueName(ctx context.Context) string

GetQueueName returns the queue name from the specified context, if present. Otherwise it returns config.DefaultQueueName.

func GetTaskID added in v0.1.14

func GetTaskID(ctx context.Context) string

GetTaskID returns the ID of the task from the specified context, if present.

func NewDefaultErrorHandler

func NewDefaultErrorHandler() asynq.ErrorHandlerFunc

NewDefaultErrorHandler returns an asynq.ErrorHandlerFunc, which logs the task and the reason why it has failed.

func NewLoggerMiddleware

func NewLoggerMiddleware(logger *slog.Logger) asynq.MiddlewareFunc

NewLoggerMiddleware returns a new asynq.MiddlewareFunc, which embeds a slog.Logger in the context provided to task handlers.

func NewMeasuringMiddleware

func NewMeasuringMiddleware() asynq.MiddlewareFunc

NewMeasuringMiddleware returns a new asynq.MiddlewareFunc which measures the execution of tasks.

func NewMetricsMiddleware added in v0.1.14

func NewMetricsMiddleware() asynq.MiddlewareFunc

NewMetricsMiddleware returns a new asynq.MiddlewareFunc which provides metrics about task handlers.

func NewRedisClientOptFromConfig added in v0.1.9

func NewRedisClientOptFromConfig(conf config.RedisConfig) asynq.RedisClientOpt

NewRedisClientOptFromConfig returns an asynq.RedisClientOpt from the provided config.RedisConfig configuration.

func SkipRetry

func SkipRetry(err error) error

SkipRetry wraps the provided error with asynq.SkipRetry in order to signal asynq that the task should not retried.

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal unmarshals the given payload data by first attempting to unmarshal using json.Unmarshal, and if not successful then falls back to yaml.Unmarshal.

Types

type TaskConstructor added in v0.1.9

type TaskConstructor func() *asynq.Task

TaskConstructor is a function which creates and returns a new asynq.Task.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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