queue

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package queue provides CLI integration for the pg-boss queue/jobs plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PurgeQueue

func PurgeQueue(ctx context.Context, dbURL, queue string, olderThan time.Duration) (int, error)

PurgeQueue removes completed/dead jobs older than the specified duration. The DELETE runs inside a transaction that first takes a transaction-scoped advisory lock so concurrent purges cannot fight over the same rows.

func RetryJob

func RetryJob(ctx context.Context, dbURL, jobID string) error

RetryJob moves a failed/dead job back to pending state.

Types

type CronEntry

type CronEntry struct {
	Name     string `json:"name"`
	Queue    string `json:"queue"`
	Schedule string `json:"schedule"`
	Enabled  bool   `json:"enabled"`
}

CronEntry represents a scheduled cron job.

func ListCrons

func ListCrons(ctx context.Context, dbURL string) ([]CronEntry, error)

ListCrons returns scheduled cron jobs.

type Job

type Job struct {
	ID         string          `json:"id"`
	Queue      string          `json:"queue"`
	State      string          `json:"state"` // pending, active, completed, failed, dead
	Data       json.RawMessage `json:"data"`
	CreatedAt  time.Time       `json:"created_at"`
	StartedAt  *time.Time      `json:"started_at,omitempty"`
	DoneAt     *time.Time      `json:"done_at,omitempty"`
	RetryCount int             `json:"retry_count"`
	Error      string          `json:"error,omitempty"`
}

Job represents a queue job.

func ListJobs

func ListJobs(ctx context.Context, dbURL, queue, state string, limit int) ([]Job, error)

ListJobs returns jobs for a queue, optionally filtered by state.

type QueueInfo

type QueueInfo struct {
	Name    string `json:"name"`
	Pending int    `json:"pending"`
	Active  int    `json:"active"`
	Failed  int    `json:"failed"`
	Dead    int    `json:"dead"`
}

QueueInfo holds summary information about a queue.

func ListQueues

func ListQueues(ctx context.Context, dbURL string) ([]QueueInfo, error)

ListQueues queries the database for queue summary information.

Jump to

Keyboard shortcuts

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