Documentation
¶
Overview ¶
Package asynq provides various asynq utilities
Package asynq provides various asynq utilities
Index ¶
- func Enqueue(ctx context.Context, items []TaskConstructor, opts ...asynq.Option) error
- func GetLogger(ctx context.Context) *slog.Logger
- func GetQueueName(ctx context.Context) string
- func GetTaskID(ctx context.Context) string
- func NewDefaultErrorHandler() asynq.ErrorHandlerFunc
- func NewLoggerMiddleware(logger *slog.Logger) asynq.MiddlewareFunc
- func NewMeasuringMiddleware() asynq.MiddlewareFunc
- func NewMetricsMiddleware() asynq.MiddlewareFunc
- func NewRedisClientOptFromConfig(conf config.RedisConfig) asynq.RedisClientOpt
- func SkipRetry(err error) error
- func Unmarshal(data []byte, v any) error
- type TaskConstructor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLogger ¶
GetLogger returns the slog.Logger instance from the provided context, if found, or slog.DefaultLogger otherwise.
func GetQueueName ¶ added in v0.1.8
GetQueueName returns the queue name from the specified context, if present. Otherwise it returns config.DefaultQueueName.
func GetTaskID ¶ added in v0.1.14
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 ¶
SkipRetry wraps the provided error with asynq.SkipRetry in order to signal asynq that the task should not retried.
func Unmarshal ¶
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
TaskConstructor is a function which creates and returns a new asynq.Task.