Documentation
¶
Index ¶
- Constants
- func EnqueueExampleTask(client asynqClient, message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
- func EnqueueExampleTaskContext(ctx context.Context, client asynqClient, message *ExampleTask, ...) (*asynq.Task, *asynq.TaskInfo, error)
- func EnqueueExampleTaskContextWithHeaders(ctx context.Context, client asynqClient, message *ExampleTask, ...) (*asynq.Task, *asynq.TaskInfo, error)
- func EnqueueExampleTaskWithHeaders(client asynqClient, message *ExampleTask, headers map[string]string, ...) (*asynq.Task, *asynq.TaskInfo, error)
- func NewExampleTaskProcessor(fn ExampleTaskProcessor) func(context.Context, *asynq.Task) error
- func NewExampleTaskTask(t *ExampleTask) (*asynq.Task, error)
- func NewExampleTaskTaskWithHeaders(t *ExampleTask, headers map[string]string) (*asynq.Task, error)
- type Dispatcher
- func (d *Dispatcher) EnqueueExampleTask(message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
- func (d *Dispatcher) EnqueueExampleTaskContext(ctx context.Context, message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
- func (d *Dispatcher) EnqueueExampleTaskContextWithHeaders(ctx context.Context, message *ExampleTask, headers map[string]string, ...) (*asynq.Task, *asynq.TaskInfo, error)
- func (d *Dispatcher) EnqueueExampleTaskWithHeaders(message *ExampleTask, headers map[string]string, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
- type ExampleTask
- type ExampleTaskProcessor
- type Processors
- func (p *Processors) Handle(mux asynqMux)
- func (p *Processors) HandleAll(mux asynqMux) error
- func (p *Processors) NewServeMux(middlewares ...asynq.MiddlewareFunc) (*asynq.ServeMux, error)
- func (p *Processors) Run(ctx context.Context, redisConnOpt asynq.RedisConnOpt, cfg asynq.Config, ...) error
- func (p *Processors) RunWithRedisClient(ctx context.Context, client redis.UniversalClient, cfg asynq.Config, ...) error
Constants ¶
const (
// TypeExampleTask is wired to [asynq.Task.Type], [asynq.ServeMux.Handle] and [asynq.ServeMux.HandleFunc].
TypeExampleTask = "example02:sample_task"
)
Auto-generated constants for use with asynq.NewTask, asynq.ServeMux.Handle, and asynq.ServeMux.HandleFunc.
Variables ¶
This section is empty.
Functions ¶
func EnqueueExampleTask ¶ added in v0.26.10
func EnqueueExampleTask(client asynqClient, message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTask pushes a ExampleTask task to the queue.
Additional asynq.Option can be passed to override the options set by NewExampleTaskTask.
This function is auto-generated.
func EnqueueExampleTaskContext ¶
func EnqueueExampleTaskContext(ctx context.Context, client asynqClient, message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTaskContext pushes a ExampleTask task to the queue.
Additional asynq.Option can be passed to override the options set by NewExampleTaskTask.
This function is auto-generated.
func EnqueueExampleTaskContextWithHeaders ¶ added in v0.26.10
func EnqueueExampleTaskContextWithHeaders(ctx context.Context, client asynqClient, message *ExampleTask, headers map[string]string, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTaskContextWithHeaders pushes a ExampleTask task to the queue.
It supports task headers introduced with asynq 0.26.0.
Additional asynq.Option can be passed to override the options set by NewExampleTaskTask.
This function is auto-generated.
func EnqueueExampleTaskWithHeaders ¶ added in v0.26.10
func EnqueueExampleTaskWithHeaders(client asynqClient, message *ExampleTask, headers map[string]string, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTaskWithHeaders pushes a ExampleTask task to the queue.
It supports task headers introduced with asynq 0.26.0.
Additional asynq.Option can be passed to override the options set by NewExampleTaskTask.
This function is auto-generated.
func NewExampleTaskProcessor ¶
NewExampleTaskProcessor wraps a ExampleTaskProcessor function so that it can be passed to asynq.ServeMux.Handle and asynq.ServeMux.HandleFunc.
Notes about the returned function:
- it will reject nil tasks and tasks of which the typename does not match TypeExampleTask.
- it will return an error if a task's payload cannot be unmarshalled.
- it will return any received error as-is, including asynq.SkipRetry and asynq.RevokeTask.
This function is auto-generated.
func NewExampleTaskTask ¶
func NewExampleTaskTask(t *ExampleTask) (*asynq.Task, error)
NewExampleTaskTask calls NewExampleTaskTaskWithHeaders with nil headers.
This function is auto-generated.
func NewExampleTaskTaskWithHeaders ¶ added in v0.26.10
NewExampleTaskTaskWithHeaders takes a ExampleTask pointer and returns a new asynq.Task with its typename set to TypeExampleTask.
It calls asynq.NewTaskWithHeaders introduced with asynq 0.26.0.
It returns an error if the pointer is nil, or if it cannot be marshalled.
Task's options:
- Max retries: 1
- Retention: 24h0m0s
- Timeout: 10s
This function is auto-generated.
Types ¶
type Dispatcher ¶ added in v0.26.10
type Dispatcher struct {
Client asynqClient
}
Dispatcher defines methods to enqueue messages, using the already exported Enqueue* methods.
This type is auto-generated.
func (*Dispatcher) EnqueueExampleTask ¶ added in v0.26.10
func (d *Dispatcher) EnqueueExampleTask(message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTask invokes EnqueueExampleTask.
This method is auto-generated.
func (*Dispatcher) EnqueueExampleTaskContext ¶ added in v0.26.10
func (d *Dispatcher) EnqueueExampleTaskContext(ctx context.Context, message *ExampleTask, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTaskContext invokes EnqueueExampleTaskContext.
This method is auto-generated.
func (*Dispatcher) EnqueueExampleTaskContextWithHeaders ¶ added in v0.26.10
func (d *Dispatcher) EnqueueExampleTaskContextWithHeaders(ctx context.Context, message *ExampleTask, headers map[string]string, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTaskContextWithHeaders invokes EnqueueExampleTaskContextWithHeaders.
This method is auto-generated.
func (*Dispatcher) EnqueueExampleTaskWithHeaders ¶ added in v0.26.10
func (d *Dispatcher) EnqueueExampleTaskWithHeaders(message *ExampleTask, headers map[string]string, opts ...asynq.Option) (*asynq.Task, *asynq.TaskInfo, error)
EnqueueExampleTaskWithHeaders invokes a EnqueueExampleTaskWithHeaders.
This method is auto-generated.
type ExampleTask ¶
type ExampleTask struct {
ExampleContent string
}
asynq:task sample_task asynq:retention 1d asynq:retry 1 asynq:timeout 10s
func NewExampleTaskFromJSON ¶
func NewExampleTaskFromJSON(r io.Reader) (*ExampleTask, error)
NewExampleTaskFromJSON consumes a JSON input and returns a ExampleTask. Any error returned by json.Unmarshal will be returned as-is.
This function is auto-generated.
func NewExampleTaskFromJSONBytes ¶
func NewExampleTaskFromJSONBytes(b []byte) (*ExampleTask, error)
NewExampleTaskFromJSONBytes reads a JSON bytestream and returns a ExampleTask.
Any error returned by json.Unmarshal will be returned as-is.
This function is auto-generated.
type ExampleTaskProcessor ¶
ExampleTaskProcessor describes a function that processes ExampleTask.
This type is auto-generated.
type Processors ¶
type Processors struct {
ExampleTask ExampleTaskProcessor
}
Processors defines methods to process messages by their type.
This type is auto-generated.
func (*Processors) Handle ¶
func (p *Processors) Handle(mux asynqMux)
Handle register all non-nil handlers with asynq.ServeMux.HandleFunc.
This function is auto-generated.
func (*Processors) HandleAll ¶
func (p *Processors) HandleAll(mux asynqMux) error
HandleAll register all handlers with asynq.ServeMux.HandleFunc. It returns an error if any handler is nil.
This function is auto-generated.
func (*Processors) NewServeMux ¶ added in v0.26.10
func (p *Processors) NewServeMux(middlewares ...asynq.MiddlewareFunc) (*asynq.ServeMux, error)
NewServeMux wires up a new asynq.ServeMux with the provided middlewares and the Processors handlers.
This function is auto-generated.
func (*Processors) Run ¶ added in v0.26.10
func (p *Processors) Run(ctx context.Context, redisConnOpt asynq.RedisConnOpt, cfg asynq.Config, middlewares ...asynq.MiddlewareFunc) error
Run invokes Processors.NewServeMux, asynq.Server.Start, and returns any error encountered by either method. It then waits for the context to be done before stopping and shutting down the server.
Note the context passed to this method must be cancelled explicitly (e.g.: signal.NotifyContext, errgroup.WithContext, or testing.T.Context) for the method to return.
This function is auto-generated.
func (*Processors) RunWithRedisClient ¶ added in v0.26.12
func (p *Processors) RunWithRedisClient(ctx context.Context, client redis.UniversalClient, cfg asynq.Config, middlewares ...asynq.MiddlewareFunc) error
RunWithRedisClient invokes Processors.NewServeMux, asynq.Server.Start, and returns any error encountered by either method. It then waits for the context to be done before stopping and shutting down the server.
Note the context passed to this method must be cancelled explicitly (e.g.: signal.NotifyContext, errgroup.WithContext, or testing.T.Context) for the method to return.
Also, the redis.UniversalClient connection pool must be closed upstream, explicitly.
This function is auto-generated.