Versions in this module Expand all Collapse all v1 v1.1.0 Aug 16, 2026 Changes in this version + var ErrAlreadyStarted = errors.New("pgqueue: already started") type Job + CreatedAt time.Time + type Middleware func(next Handler) Handler type Queue + func (q *Queue) Prune(ctx context.Context, olderThan time.Duration) (int64, error) type WorkerConfig + JobTimeout time.Duration + Middleware []Middleware + Retain time.Duration v1.0.0 Aug 14, 2026 Changes in this version + const Schema + const SchemaDown + func DefaultBackoff(attempt int) time.Duration + func IsPermanent(err error) bool + func Permanent(err error) error + func Publish(ctx context.Context, db DBTX, channel string, payload []byte) error + type DBTX interface + ExecContext func(ctx context.Context, query string, args ...any) (sql.Result, error) + QueryRowContext func(ctx context.Context, query string, args ...any) *sql.Row + type EnqueueOption func(*enqueueSettings) + func WithMaxAttempts(n int) EnqueueOption + func WithRunAt(t time.Time) EnqueueOption + type Handler func(ctx context.Context, job Job) error + type Job struct + Attempts int + ID int64 + LastError string + MaxAttempts int + Payload json.RawMessage + Queue string + RunAt time.Time + Type string + type Logger interface + Debug func(msg string, keyVals ...any) + Error func(msg string, keyVals ...any) + Info func(msg string, keyVals ...any) + Warn func(msg string, keyVals ...any) + type Option func(*Queue) + func WithDefaultMaxAttempts(n int) Option + func WithLogger(l Logger) Option + func WithQueueName(name string) Option + type Queue struct + func New(db *sql.DB, opts ...Option) *Queue + func (q *Queue) Enqueue(ctx context.Context, jobType string, payload []byte, opts ...EnqueueOption) (int64, error) + func (q *Queue) EnqueueTx(ctx context.Context, tx *sql.Tx, jobType string, payload []byte, ...) (int64, error) + type Status string + const StatusCompleted + const StatusDead + const StatusPending + const StatusRunning + type Subscriber struct + func NewSubscriber(dsn string, logger Logger) *Subscriber + func (s *Subscriber) Handle(channel string, fn func(payload []byte)) + func (s *Subscriber) Start(ctx context.Context) error + type Worker struct + func NewWorker(db *sql.DB, cfg WorkerConfig) *Worker + func (w *Worker) Register(jobType string, h Handler) + func (w *Worker) Start(ctx context.Context) error + func (w *Worker) Stop(ctx context.Context) error + type WorkerConfig struct + Backoff func(attempt int) time.Duration + Concurrency int + ListenDSN string + Logger Logger + PollInterval time.Duration + QueueName string + RescueAfter time.Duration