Documentation
¶
Overview ¶
Package queue provides explicit background jobs with typed handler registration, an inline sync driver for development, and a Redis (asynq) driver for production with retries, delays, and graceful drain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HandlerFunc ¶
HandlerFunc processes one job payload.
type Option ¶
type Option func(*jobOptions)
Option customizes a single dispatch.
type Options ¶
type Options struct {
// Driver selects the backend: "sync" (default, executes jobs inline) or
// "redis" (asynq worker with retries and graceful drain).
Driver string
// RedisURL configures the redis driver, e.g. redis://localhost:6379/0.
RedisURL string
// Concurrency is the redis worker goroutine count, defaulting to 10.
Concurrency int
// Queues maps queue names to priorities; defaults to {"default": 1}.
Queues map[string]int
// ShutdownTimeout bounds the in-flight drain on stop, defaulting to 8s.
ShutdownTimeout time.Duration
Logger *slog.Logger
}
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue dispatches and processes background jobs.
func (*Queue) Handle ¶
func (q *Queue) Handle(name string, handler HandlerFunc)
Handle registers a raw payload handler for the named job. Register every handler before Start; later registrations are not picked up by a running worker.
type QueueStats ¶
type QueueStats struct {
Name string `json:"name"`
Pending int `json:"pending"`
Active int `json:"active"`
Scheduled int `json:"scheduled"`
Retry int `json:"retry"`
Archived int `json:"archived"`
Completed int `json:"completed"`
}
QueueStats reports the task counts of one named queue.
type Stats ¶
type Stats struct {
Driver string `json:"driver"`
Queues []QueueStats `json:"queues,omitempty"`
}
Stats reports the driver backing the queue and per-queue task counts. The sync driver executes jobs inline, so it reports no queues.